DispatchQueueAttr

Struct DispatchQueueAttr 

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

Dispatch queue attribute.

Implementations§

Source§

impl DispatchQueueAttr

Source

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

Source

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.

Source

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.

Source§

impl DispatchQueueAttr

Source

pub const SERIAL: Option<&Self> = None

A dispatch queue that executes blocks serially in FIFO order.

Source

pub fn concurrent() -> Option<&'static Self>

A dispatch queue that executes blocks concurrently.

Trait Implementations§

Source§

impl AsRef<AnyObject> for DispatchQueueAttr

Source§

fn as_ref(&self) -> &AnyObject

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

impl AsRef<DispatchQueueAttr> for DispatchQueueAttr

Source§

fn as_ref(&self) -> &Self

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

impl Debug for DispatchQueueAttr

Source§

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

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

impl DispatchObject for DispatchQueueAttr

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 DispatchQueueAttr

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 DispatchQueueAttr

Source§

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

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

impl PartialEq for DispatchQueueAttr

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 DispatchQueueAttr

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 DispatchQueueAttr

Source§

impl Send for DispatchQueueAttr

Source§

impl Sync for DispatchQueueAttr

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<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,