XTaskQueueDispatch
Processes an item in the task queue for the given port.Syntax
Parameters
queue _In_Type: XTaskQueueHandle The queue to dispatch work on. port _In_
Type: XTaskQueuePort The port to dispatch. timeoutInMs _In_
Type: uint32_t The number of milliseconds to wait for work to arrive before returning false. You may pass INFINITE to wait forever.
Return value
Type: bool Returns true if this function dispatched a call or false if it did not. This function will also return false if the queue is terminated, even if INFINITE is passed as a timeout.Remarks
You can pass a timeout, which will cause XTaskQueueDispatch to wait for something to arrive in the queue. If a task queue port was created with XTaskQueueDispatchMode::ThreadPool, XTaskQueueDispatchMode::SerializedThreadPool, or XTaskQueueDispatchMode::Immediate, dispatch modes it will dispatch callbacks automatically. For manual dispatch ports you need to call XTaskQueueDispatch. XTaskQueueDispatch can be called for any dispatch mode but note that a call is always dispatched on the thread that calls XTaskQueueDispatch.Adding an item to a queue needs to be lock and wait free in order to satisfy the performance requirements of upstream code. The following APIs are lock free:
- XTaskQueueSubmitCallback
- XTaskQueueSubmitDelayedCallback
- XTaskQueueDispatch, provided that 0 is passed for timeoutInMs
The amount of time spent by XTaskQueueDispatch when processing an item from the Work port is variable and dependent on the work being performed. In some cases the calling thread could block waiting for other system work to complete. The following example shows how to use the XTaskQueueDispatch function to process items in the task queue.
SubmitCallback is a helper function that is defined in the code example for the XTaskQueueSubmitCallback function.
Requirements
Header: XTaskQueue.h Library: xgameruntime.lib Supported platforms: Windows, XBOX One family consoles and XBOX Series consolesConceptual documentation
- Clean up task queue
- Dispatch task queue
- XTaskQueue library overview
- Asynchronous Programming Model
- Asynchronous programming design goals and improvements
See also
XTaskQueue membersAsynchronous Programming Model
Async Task Queue Design
