#[repr(C)]pub struct DispatchQueueAttr { /* private fields */ }Expand description
Dispatch queue attribute.
Implementations§
Source§impl DispatchQueueAttr
impl DispatchQueueAttr
Sourcepub fn new_initially_inactive(
attr: Option<&DispatchQueueAttr>,
) -> DispatchRetained<DispatchQueueAttr> ⓘ
pub fn new_initially_inactive( attr: Option<&DispatchQueueAttr>, ) -> DispatchRetained<DispatchQueueAttr> ⓘ
Returns an attribute value which may be provided to dispatch_queue_create() or dispatch_queue_create_with_target(), in order to make the created queue initially inactive.
Dispatch queues may be created in an inactive state. Queues in this state have to be activated before any blocks associated with them will be invoked.
A queue in inactive state cannot be deallocated, dispatch_activate() must be called before the last reference to a queue created with this attribute is released.
The target queue of a queue in inactive state can be changed using dispatch_set_target_queue(). Change of target queue is no longer permitted once an initially inactive queue has been activated.
Parameter attr: A queue attribute value to be combined with the initially inactive attribute.
Returns: Returns an attribute value which may be provided to dispatch_queue_create() and dispatch_queue_create_with_target(). The new value combines the attributes specified by the ‘attr’ parameter with the initially inactive attribute.
Source§impl DispatchQueueAttr
impl DispatchQueueAttr
Sourcepub fn with_autorelease_frequency(
attr: Option<&DispatchQueueAttr>,
frequency: DispatchAutoReleaseFrequency,
) -> DispatchRetained<DispatchQueueAttr> ⓘ
pub fn with_autorelease_frequency( attr: Option<&DispatchQueueAttr>, frequency: DispatchAutoReleaseFrequency, ) -> DispatchRetained<DispatchQueueAttr> ⓘ
Returns a dispatch queue attribute value with the autorelease frequency set to the specified value.
When a queue uses the per-workitem autorelease frequency (either directly
or inherited from its target queue), any block submitted asynchronously to
this queue (via dispatch_async(), dispatch_barrier_async(),
dispatch_group_notify(), etc…) is executed as if surrounded by a individual
Objective-C
objc2::rc::autoreleasepool
scope.
Autorelease frequency has no effect on blocks that are submitted synchronously to a queue (via dispatch_sync(), dispatch_barrier_sync()).
The global concurrent queues have the DISPATCH_AUTORELEASE_FREQUENCY_NEVER behavior. Manually created dispatch queues use DISPATCH_AUTORELEASE_FREQUENCY_INHERIT by default.
Queues created with this attribute cannot change target queues after having been activated. See dispatch_set_target_queue() and dispatch_activate().
Parameter attr: A queue attribute value to be combined with the specified autorelease
frequency or NULL.
Parameter frequency: The requested autorelease frequency.
Returns: Returns an attribute value which may be provided to dispatch_queue_create() or NULL if an invalid autorelease frequency was requested. This new value combines the attributes specified by the ‘attr’ parameter and the chosen autorelease frequency.
Sourcepub fn with_qos_class(
attr: Option<&DispatchQueueAttr>,
qos_class: DispatchQoS,
relative_priority: c_int,
) -> DispatchRetained<DispatchQueueAttr> ⓘ
pub fn with_qos_class( attr: Option<&DispatchQueueAttr>, qos_class: DispatchQoS, relative_priority: c_int, ) -> DispatchRetained<DispatchQueueAttr> ⓘ
Returns an attribute value which may be provided to dispatch_queue_create() or dispatch_queue_create_with_target(), in order to assign a QOS class and relative priority to the queue.
When specified in this manner, the QOS class and relative priority take precedence over those inherited from the dispatch queue’s target queue (if any) as long that does not result in a lower QOS class and relative priority.
The global queue priorities map to the following QOS classes:
- DISPATCH_QUEUE_PRIORITY_HIGH: QOS_CLASS_USER_INITIATED
- DISPATCH_QUEUE_PRIORITY_DEFAULT: QOS_CLASS_DEFAULT
- DISPATCH_QUEUE_PRIORITY_LOW: QOS_CLASS_UTILITY
- DISPATCH_QUEUE_PRIORITY_BACKGROUND: QOS_CLASS_BACKGROUND
Example:
dispatch_queue_t queue;
dispatch_queue_attr_t attr;
attr = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL,
QOS_CLASS_UTILITY, 0);
queue = dispatch_queue_create(“com.example.myqueue”, attr);
The QOS class and relative priority set this way on a queue have no effect on blocks that are submitted synchronously to a queue (via dispatch_sync(), dispatch_barrier_sync()).
Parameter attr: A queue attribute value to be combined with the QOS class, or NULL.
Parameter qos_class: A QOS class value:
- QOS_CLASS_USER_INTERACTIVE
- QOS_CLASS_USER_INITIATED
- QOS_CLASS_DEFAULT
- QOS_CLASS_UTILITY
- QOS_CLASS_BACKGROUND Passing any other value results in NULL being returned.
Parameter relative_priority: A relative priority within the QOS class. This value is a negative
offset from the maximum supported scheduler priority for the given class.
Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY
results in NULL being returned.
Returns: Returns an attribute value which may be provided to dispatch_queue_create() and dispatch_queue_create_with_target(), or NULL if an invalid QOS class was requested. The new value combines the attributes specified by the ‘attr’ parameter and the new QOS class and relative priority.
Trait Implementations§
Source§impl AsRef<AnyObject> for DispatchQueueAttr
impl AsRef<AnyObject> for DispatchQueueAttr
Source§impl AsRef<DispatchQueueAttr> for DispatchQueueAttr
impl AsRef<DispatchQueueAttr> for DispatchQueueAttr
Source§impl Debug for DispatchQueueAttr
impl Debug for DispatchQueueAttr
Source§impl DispatchObject for DispatchQueueAttr
impl DispatchObject for DispatchQueueAttr
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