Asynchronous task interface. More...
#include <ThreadPool.h>
Public Member Functions | |
| virtual ASYNC_TASK_STATUS DILIGENT_CALL_TYPE | Run (Uint32 ThreadId)=0 |
| Run the asynchronous task. | |
| virtual void DILIGENT_CALL_TYPE | Cancel ()=0 |
| Requests task cancellation, if possible. | |
| virtual void DILIGENT_CALL_TYPE | SetStatus (ASYNC_TASK_STATUS TaskStatus)=0 |
| Sets the task status, see Diligent::ASYNC_TASK_STATUS. | |
| virtual ASYNC_TASK_STATUS DILIGENT_CALL_TYPE | GetStatus () const =0 |
| Gets the task status, see Diligent::ASYNC_TASK_STATUS. | |
| virtual void DILIGENT_CALL_TYPE | SetPriority (float fPriority)=0 |
| Sets the task priority. | |
| virtual float DILIGENT_CALL_TYPE | GetPriority () const =0 |
| Returns the task priority. | |
| virtual bool DILIGENT_CALL_TYPE | IsFinished () const =0 |
| Checks if the task is finished (i.e. cancelled or complete). | |
| virtual void DILIGENT_CALL_TYPE | WaitForCompletion () const =0 |
| Waits until the task is complete. | |
| virtual void DILIGENT_CALL_TYPE | WaitUntilRunning () const =0 |
| Waits until the task leaves the Diligent::ASYNC_TASK_STATUS_NOT_STARTED state. | |
| Public Member Functions inherited from Diligent.IObject | |
| virtual void DILIGENT_CALL_TYPE | QueryInterface (const INTERFACE_ID &IID, IObject **ppInterface)=0 |
| Queries the specific interface. | |
| template<typename DerivedType, typename = typename std::enable_if<std::is_base_of<IObject, DerivedType>::value>::type> | |
| void | QueryInterface (const INTERFACE_ID &IID, DerivedType **ppInterface) |
| virtual ReferenceCounterValueType DILIGENT_CALL_TYPE | AddRef ()=0 |
| Increments the number of strong references by 1. | |
| virtual ReferenceCounterValueType DILIGENT_CALL_TYPE | Release ()=0 |
| virtual IReferenceCounters *DILIGENT_CALL_TYPE | GetReferenceCounters () const =0 |
Asynchronous task interface.
|
pure virtual |
Requests task cancellation, if possible.
This is a cooperative cancellation request. If the task is running, the task implementation should observe the request and abort execution, if possible. Calling this method does not remove the task from a thread pool queue and does not guarantee that a task in the Diligent::ASYNC_TASK_STATUS_NOT_STARTED state immediately transitions to Diligent::ASYNC_TASK_STATUS_CANCELLED.
To cancel a queued task that has not started, use IThreadPool::RemoveTask().
|
pure virtual |
Run the asynchronous task.
| [in] | ThreadId | - Id of the thread that is running this task. |
Before starting the task, the thread pool sets its status to Diligent::ASYNC_TASK_STATUS_RUNNING.
The method must return one of the following values:
The thread pool will set the task status to the returned value after the Run() method completes. This way if the GetStatus() method returns any value other than Diligent::ASYNC_TASK_STATUS_RUNNING, it is guaranteed that the task is not executed by any thread.
|
pure virtual |
Sets the task priority.
NaN priority is invalid. Implementations will report an error and use the default priority 0 instead.
|
pure virtual |
Waits until the task is complete.
|
pure virtual |
Waits until the task leaves the Diligent::ASYNC_TASK_STATUS_NOT_STARTED state.
When this method returns, the task may be running, complete, or cancelled. A fast task may reach Diligent::ASYNC_TASK_STATUS_COMPLETE before the waiting thread wakes up, so this method does not guarantee that the task is still running when it returns.
This method must not be called from the worker thread.