Commit 23c1158 1 parent bccb4f2 commit 23c1158 Copy full SHA for 23c1158
File tree 2 files changed +7
-0
lines changed
2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ task_token& task::start(thread_pool& pool)
36
36
37
37
// Reset flags for a running task
38
38
m_running = true ;
39
+ m_enqueued = true ;
39
40
m_completed = false ;
40
41
m_token.reset ();
41
42
@@ -45,6 +46,7 @@ task_token& task::start(thread_pool& pool)
45
46
46
47
void task::in_worker_thread ()
47
48
{
49
+ m_enqueued = false ;
48
50
try {
49
51
if (!m_token.canceled ())
50
52
m_execute (m_token);
Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ class task {
67
67
68
68
bool running () const { return m_running; }
69
69
70
+ // Returns true when the task is enqueued in the thread pool's work queue,
71
+ // and false when the task is actually being executed.
72
+ bool enqueued () const { return m_enqueued; }
73
+
70
74
// Returns true when the task is completed (whether it was
71
75
// canceled or not). If this is true, it's safe to delete the task
72
76
// instance (it will not be used anymore by any othe background
@@ -77,6 +81,7 @@ class task {
77
81
void in_worker_thread ();
78
82
79
83
std::atomic<bool > m_running;
84
+ std::atomic<bool > m_enqueued;
80
85
std::atomic<bool > m_completed;
81
86
task_token m_token;
82
87
func_t m_execute;
You can’t perform that action at this time.
0 commit comments