@@ -90,10 +90,16 @@ DILIGENT_BEGIN_INTERFACE(IAsyncTask, IObject)
9090 VIRTUAL ASYNC_TASK_STATUS METHOD (Run)(THIS_
9191 Uint32 ThreadId) PURE ;
9292
93- // / Cancel the task, if possible.
94-
95- // / If the task is running, the task implementation should
96- // / abort the task execution, if possible.
93+ // / Requests task cancellation, if possible.
94+
95+ // / This is a cooperative cancellation request. If the task is running, the
96+ // / task implementation should observe the request and abort execution, if
97+ // / possible. Calling this method does not remove the task from a thread
98+ // / pool queue and does not guarantee that a task in the
99+ // / Diligent::ASYNC_TASK_STATUS_NOT_STARTED state immediately transitions to
100+ // / Diligent::ASYNC_TASK_STATUS_CANCELLED.
101+ // /
102+ // / To cancel a queued task that has not started, use IThreadPool::RemoveTask().
97103 VIRTUAL void METHOD (Cancel)(THIS ) PURE ;
98104
99105 // / Sets the task status, see Diligent::ASYNC_TASK_STATUS.
@@ -103,11 +109,14 @@ DILIGENT_BEGIN_INTERFACE(IAsyncTask, IObject)
103109 // / Gets the task status, see Diligent::ASYNC_TASK_STATUS.
104110 VIRTUAL ASYNC_TASK_STATUS METHOD (GetStatus)(THIS ) CONST PURE ;
105111
106- // / Sets the task priorirty.
112+ // / Sets the task priority.
113+
114+ // / NaN priority is invalid. Implementations will report an error and use
115+ // / the default priority 0 instead.
107116 VIRTUAL void METHOD (SetPriority)(THIS_
108117 float fPriority ) PURE ;
109118
110- // / Returns the task priorirty .
119+ // / Returns the task priority .
111120 VIRTUAL float METHOD (GetPriority)(THIS ) CONST PURE ;
112121
113122 // / Checks if the task is finished (i.e. cancelled or complete).
@@ -175,6 +184,9 @@ DILIGENT_BEGIN_INTERFACE(IThreadPool, IObject)
175184 // /
176185 // / Thread pool will keep a strong reference to the task,
177186 // / so an application is free to release it after enqueuing.
187+ // / A task object represents one scheduled execution and must not be
188+ // / enqueued again until that execution has finished or the task has been
189+ // / removed from the queue.
178190 // /
179191 // / The thread pool does not keep strong references to prerequisite tasks.
180192 // / Prerequisites are tracked weakly; if a prerequisite object expires before
@@ -220,6 +232,11 @@ DILIGENT_BEGIN_INTERFACE(IThreadPool, IObject)
220232 // /
221233 // / \return true if the task was successfully removed from the queue,
222234 // / and false otherwise.
235+ // /
236+ // / If the task is found in the queue, it is marked as
237+ // / Diligent::ASYNC_TASK_STATUS_CANCELLED. This unblocks callers waiting in
238+ // / IAsyncTask::WaitForCompletion(). Running tasks are not removed; call
239+ // / IAsyncTask::Cancel() to request cooperative cancellation of a running task.
223240 VIRTUAL bool METHOD (RemoveTask)(THIS_
224241 IAsyncTask* pTask) PURE ;
225242
@@ -230,6 +247,13 @@ DILIGENT_BEGIN_INTERFACE(IThreadPool, IObject)
230247 // / tasks in the quque are finished and the queue is empty.
231248 // / An application is responsible to make sure that all tasks
232249 // / will finish eventually.
250+ // /
251+ // / \warning This method must not be called from a task running in this
252+ // / thread pool: the task is counted as running until it returns,
253+ // / while this method waits for all running tasks to finish.
254+ // /
255+ // / \warning Deadlock may also occur if all worker threads block waiting for
256+ // / work that requires those same worker threads to make progress.
233257 VIRTUAL void METHOD (WaitForAllTasks)(THIS ) PURE ;
234258
235259
@@ -247,6 +271,9 @@ DILIGENT_BEGIN_INTERFACE(IThreadPool, IObject)
247271 // / threads exit, so this is a graceful drain-and-stop operation rather than
248272 // / an immediate cancellation of queued work.
249273 // /
274+ // / \warning This method must not be called from a worker thread of this
275+ // / pool because it joins all worker threads, including the caller.
276+ // /
250277 // / Enqueuing tasks after calling this method is an error.
251278 VIRTUAL void METHOD (StopThreads)(THIS ) PURE ;
252279
0 commit comments