#[repr(C)]pub struct DispatchQueue { /* private fields */ }Expand description
Dispatch queue.
Implementations§
Source§impl DispatchQueue
impl DispatchQueue
pub unsafe fn exec_async_with_block( self: &DispatchQueue, block: dispatch_block_t, )
Sourcepub unsafe fn exec_async_f(
self: &DispatchQueue,
context: *mut c_void,
work: dispatch_function_t,
)
pub unsafe fn exec_async_f( self: &DispatchQueue, context: *mut c_void, work: dispatch_function_t, )
Submits a function for asynchronous execution on a dispatch queue.
See dispatch_async() for details.
Parameter queue: The target dispatch queue to which the function is submitted.
The system will hold a reference on the target queue until the function
has returned.
The result of passing NULL in this parameter is undefined.
Parameter context: The application-defined context parameter to pass to the function.
Parameter work: The application-defined function to invoke on the target queue. The first
parameter passed to this function is the context provided to
dispatch_async_f().
The result of passing NULL in this parameter is undefined.
pub unsafe fn exec_sync_with_block( self: &DispatchQueue, block: dispatch_block_t, )
Sourcepub unsafe fn exec_sync_f(
self: &DispatchQueue,
context: *mut c_void,
work: dispatch_function_t,
)
pub unsafe fn exec_sync_f( self: &DispatchQueue, context: *mut c_void, work: dispatch_function_t, )
Submits a function for synchronous execution on a dispatch queue.
See dispatch_sync() for details.
Parameter queue: The target dispatch queue to which the function is submitted.
The result of passing NULL in this parameter is undefined.
Parameter context: The application-defined context parameter to pass to the function.
Parameter work: The application-defined function to invoke on the target queue. The first
parameter passed to this function is the context provided to
dispatch_sync_f().
The result of passing NULL in this parameter is undefined.
pub unsafe fn exec_sync_and_wait_with_block( self: &DispatchQueue, block: dispatch_block_t, )
Sourcepub unsafe fn exec_sync_and_wait_f(
self: &DispatchQueue,
context: *mut c_void,
work: dispatch_function_t,
)
pub unsafe fn exec_sync_and_wait_f( self: &DispatchQueue, context: *mut c_void, work: dispatch_function_t, )
Submits a function for synchronous execution on a dispatch queue.
See dispatch_async_and_wait() for details.
Parameter queue: The target dispatch queue to which the function is submitted.
The result of passing NULL in this parameter is undefined.
Parameter context: The application-defined context parameter to pass to the function.
Parameter work: The application-defined function to invoke on the target queue. The first
parameter passed to this function is the context provided to
dispatch_async_and_wait_f().
The result of passing NULL in this parameter is undefined.
pub fn apply_with_block( iterations: usize, queue: Option<&DispatchQueue>, block: &DynBlock<dyn Fn(usize)>, )
Sourcepub unsafe fn apply_f(
iterations: usize,
queue: Option<&DispatchQueue>,
context: *mut c_void,
work: unsafe extern "C-unwind" fn(*mut c_void, usize),
)
pub unsafe fn apply_f( iterations: usize, queue: Option<&DispatchQueue>, context: *mut c_void, work: unsafe extern "C-unwind" fn(*mut c_void, usize), )
Submits a function to a dispatch queue for parallel invocation.
See dispatch_apply() for details.
Parameter iterations: The number of iterations to perform.
Parameter queue: The dispatch queue to which the function is submitted.
The preferred value to pass is DISPATCH_APPLY_AUTO to automatically use
a queue appropriate for the calling thread.
Parameter context: The application-defined context parameter to pass to the function.
Parameter work: The application-defined function to invoke on the specified queue. The first
parameter passed to this function is the context provided to
dispatch_apply_f(). The second parameter passed to this function is the
current index of iteration.
The result of passing NULL in this parameter is undefined.
Sourcepub fn current() -> DispatchRetained<DispatchQueue> ⓘ
👎Deprecated: unsupported interface
pub fn current() -> DispatchRetained<DispatchQueue> ⓘ
Returns the queue on which the currently executing block is running.
Returns the queue on which the currently executing block is running.
When dispatch_get_current_queue() is called outside of the context of a submitted block, it will return the default concurrent queue.
Recommended for debugging and logging purposes only: The code must not make any assumptions about the queue returned, unless it is one of the global queues or a queue the code has itself created. The code must not assume that synchronous execution onto a queue is safe from deadlock if that queue is not the one returned by dispatch_get_current_queue().
When dispatch_get_current_queue() is called on the main thread, it may or may not return the same value as dispatch_get_main_queue(). Comparing the two is not a valid way to test whether code is executing on the main thread (see dispatch_assert_queue() and dispatch_assert_queue_not()).
This function is deprecated and will be removed in a future release.
Returns: Returns the current queue.
Source§impl DispatchQueue
impl DispatchQueue
Sourcepub fn label(queue: Option<&DispatchQueue>) -> NonNull<c_char>
pub fn label(queue: Option<&DispatchQueue>) -> NonNull<c_char>
Returns the label of the given queue, as specified when the queue was created, or the empty string if a NULL label was specified.
Passing DISPATCH_CURRENT_QUEUE_LABEL will return the label of the current queue.
Parameter queue: The queue to query, or DISPATCH_CURRENT_QUEUE_LABEL.
Returns: The label of the queue.
Sourcepub unsafe fn qos_class(
self: &DispatchQueue,
relative_priority_ptr: *mut c_int,
) -> DispatchQoS
pub unsafe fn qos_class( self: &DispatchQueue, relative_priority_ptr: *mut c_int, ) -> DispatchQoS
Returns the QOS class and relative priority of the given queue.
If the given queue was created with an attribute value returned from dispatch_queue_attr_make_with_qos_class(), this function returns the QOS class and relative priority specified at that time; for any other attribute value it returns a QOS class of QOS_CLASS_UNSPECIFIED and a relative priority of 0.
If the given queue is one of the global queues, this function returns its assigned QOS class value as documented under dispatch_get_global_queue() and a relative priority of 0; in the case of the main queue it returns the QOS value provided by qos_class_main() and a relative priority of 0.
Parameter queue: The queue to query.
Parameter relative_priority_ptr: A pointer to an int variable to be filled with the relative priority offset
within the QOS class, or NULL.
Returns: A QOS class value:
- QOS_CLASS_USER_INTERACTIVE
- QOS_CLASS_USER_INITIATED
- QOS_CLASS_DEFAULT
- QOS_CLASS_UTILITY
- QOS_CLASS_BACKGROUND
- QOS_CLASS_UNSPECIFIED
Source§impl DispatchQueue
impl DispatchQueue
pub unsafe fn exec_after_with_block( when: DispatchTime, queue: &DispatchQueue, block: dispatch_block_t, )
Sourcepub unsafe fn exec_after_f(
when: DispatchTime,
queue: &DispatchQueue,
context: *mut c_void,
work: dispatch_function_t,
)
pub unsafe fn exec_after_f( when: DispatchTime, queue: &DispatchQueue, context: *mut c_void, work: dispatch_function_t, )
Schedule a function for execution on a given queue at a specified time.
See dispatch_after() for details.
Parameter when: A temporal milestone returned by dispatch_time() or dispatch_walltime().
Parameter queue: A queue to which the given function will be submitted at the specified time.
The result of passing NULL in this parameter is undefined.
Parameter context: The application-defined context parameter to pass to the function.
Parameter work: The application-defined function to invoke on the target queue. The first
parameter passed to this function is the context provided to
dispatch_after_f().
The result of passing NULL in this parameter is undefined.
pub unsafe fn barrier_async_with_block( self: &DispatchQueue, block: dispatch_block_t, )
Sourcepub unsafe fn barrier_async_f(
self: &DispatchQueue,
context: *mut c_void,
work: dispatch_function_t,
)
pub unsafe fn barrier_async_f( self: &DispatchQueue, context: *mut c_void, work: dispatch_function_t, )
Submits a barrier function for asynchronous execution on a dispatch queue.
Submits a function to a dispatch queue like dispatch_async_f(), but marks that function as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues).
See dispatch_async_f() for details and “Dispatch Barrier API” for a description of the barrier semantics.
Parameter queue: The target dispatch queue to which the function is submitted.
The system will hold a reference on the target queue until the function
has returned.
The result of passing NULL in this parameter is undefined.
Parameter context: The application-defined context parameter to pass to the function.
Parameter work: The application-defined function to invoke on the target queue. The first
parameter passed to this function is the context provided to
dispatch_barrier_async_f().
The result of passing NULL in this parameter is undefined.
pub unsafe fn barrier_sync_with_block( self: &DispatchQueue, block: dispatch_block_t, )
Sourcepub unsafe fn barrier_sync_f(
self: &DispatchQueue,
context: *mut c_void,
work: dispatch_function_t,
)
pub unsafe fn barrier_sync_f( self: &DispatchQueue, context: *mut c_void, work: dispatch_function_t, )
Submits a barrier function for synchronous execution on a dispatch queue.
Submits a function to a dispatch queue like dispatch_sync_f(), but marks that fuction as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues).
See dispatch_sync_f() for details.
Parameter queue: The target dispatch queue to which the function is submitted.
The result of passing NULL in this parameter is undefined.
Parameter context: The application-defined context parameter to pass to the function.
Parameter work: The application-defined function to invoke on the target queue. The first
parameter passed to this function is the context provided to
dispatch_barrier_sync_f().
The result of passing NULL in this parameter is undefined.
pub unsafe fn barrier_async_and_wait_with_block( self: &DispatchQueue, block: dispatch_block_t, )
Sourcepub unsafe fn barrier_async_and_wait_f(
self: &DispatchQueue,
context: *mut c_void,
work: dispatch_function_t,
)
pub unsafe fn barrier_async_and_wait_f( self: &DispatchQueue, context: *mut c_void, work: dispatch_function_t, )
Submits a function for synchronous execution on a dispatch queue.
Submits a function to a dispatch queue like dispatch_async_and_wait_f(), but marks that function as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues).
See “Dispatch Barrier API” for a description of the barrier semantics.
Parameter queue: The target dispatch queue to which the function is submitted.
The result of passing NULL in this parameter is undefined.
Parameter context: The application-defined context parameter to pass to the function.
Parameter work: The application-defined function to invoke on the target queue. The first
parameter passed to this function is the context provided to
dispatch_barrier_async_and_wait_f().
The result of passing NULL in this parameter is undefined.
Source§impl DispatchQueue
impl DispatchQueue
Sourcepub unsafe fn specific(
self: &DispatchQueue,
key: NonNull<c_void>,
) -> *mut c_void
pub unsafe fn specific( self: &DispatchQueue, key: NonNull<c_void>, ) -> *mut c_void
Returns the subsystem-specific context associated with a dispatch queue, for a key unique to the subsystem.
Returns the context for the specified key if it has been set on the specified queue.
Parameter queue: The dispatch queue to query.
The result of passing NULL in this parameter is undefined.
Parameter key: The key to get the context for, typically a pointer to a static variable
specific to the subsystem. Keys are only compared as pointers and never
dereferenced. Passing a string constant directly is not recommended.
Returns: The context for the specified key or NULL if no context was found.
Source§impl DispatchQueue
impl DispatchQueue
Sourcepub fn assert(self: &DispatchQueue)
pub fn assert(self: &DispatchQueue)
Verifies that the current block is executing on a given dispatch queue.
Some code expects to be run on a specific dispatch queue. This function verifies that that expectation is true.
If the currently executing block was submitted to the specified queue or to any queue targeting it (see dispatch_set_target_queue()), this function returns.
If the currently executing block was submitted with a synchronous API (dispatch_sync(), dispatch_barrier_sync(), …), the context of the submitting block is also evaluated (recursively). If a synchronously submitting block is found that was itself submitted to the specified queue or to any queue targeting it, this function returns.
Otherwise this function asserts: it logs an explanation to the system log and terminates the application.
Passing the result of dispatch_get_main_queue() to this function verifies that the current block was submitted to the main queue, or to a queue targeting it, or is running on the main thread (in any context).
When dispatch_assert_queue() is called outside of the context of a submitted block (for example from the context of a thread created manually with pthread_create()) then this function will also assert and terminate the application.
The variant dispatch_assert_queue_debug() is compiled out when the preprocessor macro NDEBUG is defined. (See also assert(3)).
Parameter queue: The dispatch queue that the current block is expected to run on.
The result of passing NULL in this parameter is undefined.
Sourcepub fn assert_barrier(self: &DispatchQueue)
pub fn assert_barrier(self: &DispatchQueue)
Verifies that the current block is executing on a given dispatch queue, and that the block acts as a barrier on that queue.
This behaves exactly like dispatch_assert_queue(), with the additional check that the current block acts as a barrier on the specified queue, which is always true if the specified queue is serial (see DISPATCH_BLOCK_BARRIER or dispatch_barrier_async() for details).
The variant dispatch_assert_queue_barrier_debug() is compiled out when the preprocessor macro NDEBUG is defined. (See also assert()).
Parameter queue: The dispatch queue that the current block is expected to run as a barrier on.
The result of passing NULL in this parameter is undefined.
Sourcepub fn assert_not(self: &DispatchQueue)
pub fn assert_not(self: &DispatchQueue)
Verifies that the current block is not executing on a given dispatch queue.
This function is the equivalent of dispatch_assert_queue() with the test for equality inverted. That means that it will terminate the application when dispatch_assert_queue() would return, and vice-versa. See discussion there.
The variant dispatch_assert_queue_not_debug() is compiled out when the preprocessor macro NDEBUG is defined. (See also assert(3)).
Parameter queue: The dispatch queue that the current block is expected not to run on.
The result of passing NULL in this parameter is undefined.
Source§impl DispatchQueue
impl DispatchQueue
pub const APPLY_AUTO: Option<&DispatchQueue> = None
pub const TARGET_QUEUE_DEFAULT: Option<&DispatchQueue> = None
pub const CURRENT_QUEUE_LABEL: Option<&DispatchQueue> = None
Sourcepub fn new(
label: &str,
queue_attribute: Option<&DispatchQueueAttr>,
) -> DispatchRetained<Self> ⓘ
pub fn new( label: &str, queue_attribute: Option<&DispatchQueueAttr>, ) -> DispatchRetained<Self> ⓘ
Create a new DispatchQueue.
Sourcepub fn new_with_target(
label: &str,
queue_attribute: Option<&DispatchQueueAttr>,
target: Option<&DispatchQueue>,
) -> DispatchRetained<Self> ⓘ
pub fn new_with_target( label: &str, queue_attribute: Option<&DispatchQueueAttr>, target: Option<&DispatchQueue>, ) -> DispatchRetained<Self> ⓘ
Create a new DispatchQueue with a given target DispatchQueue.
Sourcepub fn global_queue(identifier: GlobalQueueIdentifier) -> DispatchRetained<Self> ⓘ
pub fn global_queue(identifier: GlobalQueueIdentifier) -> DispatchRetained<Self> ⓘ
Return a system-defined global concurrent DispatchQueue with the priority derived from GlobalQueueIdentifier.
Sourcepub fn exec_sync<F>(&self, work: F)
pub fn exec_sync<F>(&self, work: F)
Submit a function for synchronous execution on the DispatchQueue.
Sourcepub fn exec_async<F>(&self, work: F)
pub fn exec_async<F>(&self, work: F)
Submit a function for asynchronous execution on the DispatchQueue.
Sourcepub fn after<F>(
&self,
when: DispatchTime,
work: F,
) -> Result<(), QueueAfterError>
pub fn after<F>( &self, when: DispatchTime, work: F, ) -> Result<(), QueueAfterError>
Enqueue a function for execution at the specified time on the DispatchQueue.
Sourcepub fn barrier_async<F>(&self, work: F)
pub fn barrier_async<F>(&self, work: F)
Enqueue a barrier function for asynchronous execution on the DispatchQueue and return immediately.
Sourcepub fn barrier_sync<F>(&self, work: F)
pub fn barrier_sync<F>(&self, work: F)
Enqueue a barrier function for synchronous execution on the DispatchQueue and wait until that function completes.
Sourcepub fn barrier_async_and_wait<F>(&self, work: F)
pub fn barrier_async_and_wait<F>(&self, work: F)
Submit a function for synchronous execution and mark the function as a barrier for subsequent concurrent tasks.
Sourcepub fn set_specific<F>(&self, key: NonNull<()>, destructor: F)
pub fn set_specific<F>(&self, key: NonNull<()>, destructor: F)
Sets a function at the given key that will be executed at DispatchQueue destruction.
Sourcepub fn set_qos_class_floor(
&self,
qos_class: DispatchQoS,
relative_priority: i32,
) -> Result<(), QualityOfServiceClassFloorError>
pub fn set_qos_class_floor( &self, qos_class: DispatchQoS, relative_priority: i32, ) -> Result<(), QualityOfServiceClassFloorError>
Set the QOS class floor of the DispatchQueue.
Trait Implementations§
Source§impl AsRef<AnyObject> for DispatchQueue
impl AsRef<AnyObject> for DispatchQueue
Source§impl AsRef<DispatchQueue> for DispatchQueue
impl AsRef<DispatchQueue> for DispatchQueue
Source§impl AsRef<DispatchQueue> for DispatchWorkloop
impl AsRef<DispatchQueue> for DispatchWorkloop
Source§fn as_ref(&self) -> &DispatchQueue
fn as_ref(&self) -> &DispatchQueue
Source§impl Borrow<DispatchQueue> for DispatchWorkloop
impl Borrow<DispatchQueue> for DispatchWorkloop
Source§fn borrow(&self) -> &DispatchQueue
fn borrow(&self) -> &DispatchQueue
Source§impl Debug for DispatchQueue
impl Debug for DispatchQueue
Source§impl DispatchObject for DispatchQueue
impl DispatchObject for DispatchQueue
Source§fn retain(&self) -> DispatchRetained<Self> ⓘ
fn retain(&self) -> DispatchRetained<Self> ⓘ
Source§unsafe fn set_finalizer_f(&self, finalizer: dispatch_function_t)
unsafe fn set_finalizer_f(&self, finalizer: dispatch_function_t)
Source§fn set_finalizer<F>(&self, destructor: F)
fn set_finalizer<F>(&self, destructor: F)
Source§unsafe fn set_target_queue(&self, queue: &DispatchQueue)
unsafe fn set_target_queue(&self, queue: &DispatchQueue)
DispatchQueue of this object. Read more