CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::DispatchQueue Class Referenceabstract

An object that manages the execution of tasks serially or concurrently on your app's main thread or on a background thread. More...

#include <CeresEngine/Foundation/Threading/DispatchQueue.hpp>

Inheritance diagram for CeresEngine::DispatchQueue:
CeresEngine::ExecutionContext CeresEngine::AppleDispatchQueue CeresEngine::Win32ThreadPool

Public Member Functions

virtual void suspend ()=0
 Suspends the invocation of function objects on a queue.
 
virtual void resume ()=0
 Resumes the invocation of block objects on a queue.
 
virtual UPtr< DispatchQueuecreateSubQueue (DispatchQueueType type, StringView name="")=0
 
- Public Member Functions inherited from CeresEngine::ExecutionContext
virtual ~ExecutionContext () noexcept=default
 Virtual destructor for the execution context object.
 
template<typename T >
bool hasService () noexcept
 Determine if the ExecutionContext contains the specified service type.
 
template<typename T >
TgetService () noexcept
 Obtain the service object corresponding to the given type.
 
template<typename T >
TgetServiceIf () noexcept
 Obtain the service object corresponding to the given type.
 
virtual AnyExecutor getExecutor () noexcept=0
 Returns an executor that run execute scheduled commands on the context.
 
executor_type get_executor () noexcept
 Returns an executor that run execute scheduled commands on the context.
 
bool isActive () const noexcept
 Checks if the execution context is currently active.
 

Additional Inherited Members

- Public Types inherited from CeresEngine::ExecutionContext
using ID = id
 
using executor_type = AnyExecutor
 
- Static Public Member Functions inherited from CeresEngine::ExecutionContext
static ExecutionContextgetCurrent () noexcept
 Gets the current execution context, if any is active.
 
static ExecutionContextget () noexcept
 Gets the current execution context, if any is active.
 

Detailed Description

An object that manages the execution of tasks serially or concurrently on your app's main thread or on a background thread.

Queues are FIFO queues to which your application can submit tasks in the form of block objects. Queues execute tasks either serially or concurrently. Work submitted to queues executes on a pool of threads managed by the system. Except for the queue representing your app's main thread, the system makes no guarantees about which thread it uses to execute a task.

Member Function Documentation

◆ createSubQueue()

virtual UPtr< DispatchQueue > CeresEngine::DispatchQueue::createSubQueue ( DispatchQueueType  type,
StringView  name = "" 
)
pure virtual

◆ resume()

virtual void CeresEngine::DispatchQueue::resume ( )
pure virtual

Resumes the invocation of block objects on a queue.

Calling this function decrements the suspension count of a suspended queue. While the count is greater than zero, the queue remains suspended. When the suspension count returns to zero, any blocks submitted to the dispatch queue or any events observed by the dispatch source while suspended are delivered.

With one exception, each call to resume() must balance a call to suspend(). It is undefined to call resume() more times than suspend(), which would result in a negative suspension count.

Implemented in CeresEngine::AppleDispatchQueue, and CeresEngine::Win32ThreadPool.

◆ suspend()

virtual void CeresEngine::DispatchQueue::suspend ( )
pure virtual

Suspends the invocation of function objects on a queue.

By suspending a dispatch object, your application can temporarily prevent the execution of any functions associated with that queue.

The suspension occurs after completion of any blocks running at the time of the call. Calling this function increments the suspension count of the object, and calling resume() decrements it. While the count is greater than zero, the object remains suspended, so you must balance each suspend() call with a matching resume() call.

Any blocks submitted to a dispatch queue or events observed by a dispatch source are delivered once the object is resumed.

Note
It is a programmer error to release an object that is currently suspended, because suspension implies that there is still work to be done. Therefore, always balance calls to this method with a corresponding call to resume() before disposing of the queue. The behavior when releasing the last reference to a dispatch object while it is in a suspended state is undefined.

Implemented in CeresEngine::AppleDispatchQueue, and CeresEngine::Win32ThreadPool.


The documentation for this class was generated from the following file: