Diligent Engine
 
Loading...
Searching...
No Matches
Diligent::IAsyncTask Struct Referenceabstract

Asynchronous task interface. More...

#include <ThreadPool.h>

Inheritance diagram for Diligent::IAsyncTask:
Diligent.IObject

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
 Cancel the task, 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 priorirty.
 
virtual float DILIGENT_CALL_TYPE GetPriority () const =0
 Returns the task priorirty.
 
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 tasks is running.
 
- Public Member Functions inherited from Diligent.IObject
virtual void DILIGENT_CALL_TYPE QueryInterface (const INTERFACE_ID &IID, IObject **ppInterface)=0
 Queries the specific interface.
 
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
 

Detailed Description

Asynchronous task interface.

Member Function Documentation

◆ Cancel()

virtual void DILIGENT_CALL_TYPE Diligent::IAsyncTask::Cancel ( )
pure virtual

Cancel the task, if possible.

If the task is running, the task implementation should abort the task execution, if possible.

◆ Run()

virtual ASYNC_TASK_STATUS DILIGENT_CALL_TYPE Diligent::IAsyncTask::Run ( Uint32 ThreadId)
pure virtual

Run the asynchronous task.

Parameters
[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.

◆ WaitForCompletion()

virtual void DILIGENT_CALL_TYPE Diligent::IAsyncTask::WaitForCompletion ( ) const
pure virtual

Waits until the task is complete.

Note
This method must not be called from the same thread that is running the task or a deadlock will occur.

◆ WaitUntilRunning()

virtual void DILIGENT_CALL_TYPE Diligent::IAsyncTask::WaitUntilRunning ( ) const
pure virtual

Waits until the tasks is running.

Warning
An application is responsible to make sure that tasks currently in the queue will eventually finish allowing the task to start.

This method must not be called from the worker thread.