DispatchSemaphore

Struct DispatchSemaphore 

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

Dispatch semaphore.

Implementations§

Source§

impl DispatchSemaphore

Source

pub fn new(value: isize) -> DispatchRetained<DispatchSemaphore>

Creates new counting semaphore with an initial value.

Passing zero for the value is useful for when two threads need to reconcile the completion of a particular event. Passing a value greater than zero is useful for managing a finite pool of resources, where the pool size is equal to the value.

Parameter value: The starting value for the semaphore. Passing a value less than zero will cause NULL to be returned.

Returns: The newly created semaphore, or NULL on failure.

Source

pub fn wait(self: &DispatchSemaphore, timeout: DispatchTime) -> isize

Wait (decrement) for a semaphore.

Decrement the counting semaphore. If the resulting value is less than zero, this function waits for a signal to occur before returning. If the timeout is reached without a signal being received, the semaphore is re-incremented before the function returns.

Parameter dsema: The semaphore. The result of passing NULL in this parameter is undefined.

Parameter timeout: When to timeout (see dispatch_time). As a convenience, there are the DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants.

Returns: Returns zero on success, or non-zero if the timeout occurred.

Source

pub fn signal(self: &DispatchSemaphore) -> isize

Signal (increment) a semaphore.

Increment the counting semaphore. If the previous value was less than zero, this function wakes a waiting thread before returning.

Parameter dsema: The counting semaphore. The result of passing NULL in this parameter is undefined.

Returns: This function returns non-zero if a thread is woken. Otherwise, zero is returned.

Source§

impl DispatchSemaphore

Source

pub fn try_acquire( &self, timeout: DispatchTime, ) -> Result<DispatchSemaphoreGuard, WaitError>

Attempt to acquire the DispatchSemaphore and return a DispatchSemaphoreGuard.

§Errors

Return WaitError::TimeOverflow if the passed timeout is too big.

Return WaitError::Timeout in case of timeout.

Trait Implementations§

Source§

impl AsRef<AnyObject> for DispatchSemaphore

Source§

fn as_ref(&self) -> &AnyObject

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

impl AsRef<DispatchSemaphore> for DispatchSemaphore

Source§

fn as_ref(&self) -> &Self

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

impl Debug for DispatchSemaphore

Source§

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

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

impl DispatchObject for DispatchSemaphore

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 DispatchSemaphore

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 DispatchSemaphore

Source§

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

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

impl PartialEq for DispatchSemaphore

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 DispatchSemaphore

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 DispatchSemaphore

Source§

impl Send for DispatchSemaphore

Source§

impl Sync for DispatchSemaphore

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,