Struct DispatchWorkloop

Source
#[repr(C)]
pub struct DispatchWorkloop { /* private fields */ }
Expand description

Dispatch workloop queue.

Implementations§

Source§

impl DispatchWorkloop

Source

pub fn set_autorelease_frequency( self: &DispatchWorkloop, frequency: DispatchAutoReleaseFrequency, )

Sets the autorelease frequency of the workloop.

See dispatch_queue_attr_make_with_autorelease_frequency(). The default policy for a workloop is DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM.

Parameter workloop: The dispatch workloop to modify.

This workloop must be inactive, passing an activated object is undefined and will cause the process to be terminated.

Parameter frequency: The requested autorelease frequency.

Source§

impl DispatchWorkloop

Source

pub fn new(label: &str, inactive: bool) -> DispatchRetained<Self>

Create a new DispatchWorkloop.

Methods from Deref<Target = DispatchQueue>§

Source

pub unsafe fn exec_async_with_block( self: &DispatchQueue, block: dispatch_block_t, )

Source

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.

Source

pub unsafe fn exec_sync_with_block( self: &DispatchQueue, block: dispatch_block_t, )

Source

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.

Source

pub unsafe fn exec_sync_and_wait_with_block( self: &DispatchQueue, block: dispatch_block_t, )

Source

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.

Source

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

pub unsafe fn barrier_async_with_block( self: &DispatchQueue, block: dispatch_block_t, )

Source

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.

Source

pub unsafe fn barrier_sync_with_block( self: &DispatchQueue, block: dispatch_block_t, )

Source

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.

Source

pub unsafe fn barrier_async_and_wait_with_block( self: &DispatchQueue, block: dispatch_block_t, )

Source

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

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

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.

Source

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.

Source

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

pub const APPLY_AUTO: Option<&DispatchQueue> = None

Source

pub const TARGET_QUEUE_DEFAULT: Option<&DispatchQueue> = None

Source

pub const CURRENT_QUEUE_LABEL: Option<&DispatchQueue> = None

Source

pub fn exec_sync<F>(&self, work: F)
where F: Send + FnOnce(),

Submit a function for synchronous execution on the DispatchQueue.

Source

pub fn exec_async<F>(&self, work: F)
where F: Send + FnOnce() + 'static,

Submit a function for asynchronous execution on the DispatchQueue.

Source

pub fn after<F>( &self, when: DispatchTime, work: F, ) -> Result<(), QueueAfterError>
where F: Send + FnOnce(),

Enqueue a function for execution at the specified time on the DispatchQueue.

Source

pub fn barrier_async<F>(&self, work: F)
where F: Send + FnOnce() + 'static,

Enqueue a barrier function for asynchronous execution on the DispatchQueue and return immediately.

Source

pub fn barrier_sync<F>(&self, work: F)
where F: Send + FnOnce(),

Enqueue a barrier function for synchronous execution on the DispatchQueue and wait until that function completes.

Source

pub fn barrier_async_and_wait<F>(&self, work: F)
where F: Send + FnOnce() + 'static,

Submit a function for synchronous execution and mark the function as a barrier for subsequent concurrent tasks.

Source

pub fn set_specific<F>(&self, key: NonNull<()>, destructor: F)
where F: Send + FnOnce(),

Sets a function at the given key that will be executed at DispatchQueue destruction.

Source

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 DispatchWorkloop

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<DispatchQueue> for DispatchWorkloop

Source§

fn as_ref(&self) -> &DispatchQueue

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<DispatchWorkloop> for DispatchWorkloop

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<DispatchQueue> for DispatchWorkloop

Source§

fn borrow(&self) -> &DispatchQueue

Immutably borrows from an owned value. Read more
Source§

impl Debug for DispatchWorkloop

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for DispatchWorkloop

Source§

fn deref(&self) -> &Self::Target

Access the workloop as a DispatchQueue.

Source§

type Target = DispatchQueue

The resulting type after dereferencing.
Source§

impl DispatchObject for DispatchWorkloop

Source§

fn retain(&self) -> DispatchRetained<Self>

Increment the reference count of the object. Read more
Source§

fn context(&self) -> *mut c_void

TODO. Read more
Source§

unsafe fn set_context(&self, context: *mut c_void)

TODO. Read more
Source§

unsafe fn set_finalizer_f(&self, finalizer: dispatch_function_t)

TODO. Read more
Source§

fn set_finalizer<F>(&self, destructor: F)
where F: Send + FnOnce(),

Set the finalizer function for the object.
Source§

unsafe fn set_target_queue(&self, queue: &DispatchQueue)

Set the target DispatchQueue of this object. Read more
Source§

unsafe fn set_qos_class_floor( &self, qos_class: DispatchQoS, relative_priority: i32, ) -> Result<(), QualityOfServiceClassFloorError>

Set the QOS class floor on a dispatch queue, source or workloop. Read more
Source§

fn activate(&self)

Activate the object.
Source§

fn suspend(&self)

Suspend the invocation of functions on the object.
Source§

fn resume(&self)

Resume the invocation of functions on the object.
Source§

impl Hash for DispatchWorkloop

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for DispatchWorkloop

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl PartialEq for DispatchWorkloop

Source§

fn eq(&self, other: &Self) -> bool

Compare this [$type] with another using pointer equality.

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for DispatchWorkloop

Source§

const ENCODING_REF: Encoding = objc2::encode::Encoding::Object

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Eq for DispatchWorkloop

Source§

impl Send for DispatchWorkloop

Source§

impl Sync for DispatchWorkloop

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,