AsyncTaskQueue (object)¶
The AsyncTaskQueue manages asynchronous tasks by allowing these to be executed by [background] worker threads, with a notion of priority. Optionally, these tasks can request a “finalize” step to be executed on the main thread (to reduce synchronization issues). Also, it allows to know if some tasks have finished executing by maintaining a completedTaskCount. It allows, too, to cancel tasks or request their cancellation if these are already executing.
Members¶
Size | coreCount | |
Boolean | asyncEnabled | |
AsyncTask[] | perThreadExecutingTasks | |
AsyncTaskCircularBuffer[10] | tasksByPrio | |
AsyncTaskCircularBuffer | tasksToFinalizeOnMainThread | |
UInt32 | completedTaskCount | |
SInt32 | activeOperatorsCount | |
SInt32 | waitingAsyncTasksCount | |
SInt32 | executingTasksCount | |
SInt32 | finalizingTasksCount |
Methods¶
AsyncTaskQueue ( in AsyncTaskQueue other ) | |
AsyncTaskQueue () | |
addTask ! ( in Ref<AsyncTask> task ) | |
addTask ! ( in Ref<AsyncTask> task, in UInt8 priority ) | |
Boolean | cancelTask ! ( in Ref<AsyncTask> task ) |
Boolean | checkTasksStatus ? ( io UInt32 lastCompletedTaskCount ) |
AsyncTaskQueue | clone ? () |
enableAsynchronousEvaluation ! ( in Boolean enable ) | |
UInt32 | getExecutingTasksCount ? () |
UInt32 | getPendingTasksCount ? () |
Boolean | isCurrentThreadExecutingAsync ? () |
Boolean | tryExecuteTask ! ( in Ref<AsyncTask> task ) |
waitForAllAsyncTasks ! () | |
Boolean | waitForNextCompletion ! () |
Methods in detail¶
AsyncTaskQueue ( in AsyncTaskQueue other )
copy constructor
AsyncTaskQueue.addTask! ( in Ref<AsyncTask> task )
Adds a task to the queue, with a default priority of 5 (middle).
AsyncTaskQueue.addTask! ( in Ref<AsyncTask> task, in UInt8 priority )
Adds a task to the queue.
priority | From 0 to 9, 0 beging the highest priority. Highest priority tasks will be started before lower priority ones (however they will have to wait for already executing ones) |
Boolean AsyncTaskQueue.cancelTask! ( in Ref<AsyncTask> task )
Boolean AsyncTaskQueue.checkTasksStatus? ( io UInt32 lastCompletedTaskCount )
Returns true if some tasks were done since last check, based on lastCompletedTaskCount. This should be called from the “main” thread only, as it can trigger AsyncTask.mainThreadFinalizeWork if required by some tasks.
AsyncTaskQueue AsyncTaskQueue.clone? ()
clone method
AsyncTaskQueue.enableAsynchronousEvaluation! ( in Boolean enable )
UInt32 AsyncTaskQueue.getExecutingTasksCount? ()
Returns the number of tasks that are executing.
UInt32 AsyncTaskQueue.getPendingTasksCount? ()
Returns the number of tasks that are either queued or executing.
Boolean AsyncTaskQueue.isCurrentThreadExecutingAsync? ()
Returns true if the current thread is currently executing an async task
Boolean AsyncTaskQueue.tryExecuteTask! ( in Ref<AsyncTask> task )
AsyncTaskQueue.waitForAllAsyncTasks! ()
Boolean AsyncTaskQueue.waitForNextCompletion! ()