Struct itron_asp3::semaphore::Semaphore [−][src]
pub struct Semaphore(_);
This is supported on crate features
unstable
and dcre
only.Expand description
An owned semaphore.
Deletes the semaphore automatically when dropped. The destructor will panic if the deletion fails.
Implementations
acre_sem
: Create a builder for Semaphore
.
Examples
use itron::semaphore::Semaphore;
let binary_semaphore = Semaphore::build()
.finish()
.expect("failed to create a semaphore");
binary_semaphore.as_ref().wait()
.expect("failed to perform a wait operation");
binary_semaphore.as_ref().signal()
.expect("failed to perform a signal operation");
use itron::{semaphore::Semaphore, wait::QueueOrder};
let counting_semaphore = Semaphore::build()
.initial_count(4)
.max_count(8)
.queue_order(QueueOrder::TaskPriority)
.finish()
.expect("failed to create a semaphore");
for _ in 0..4 {
counting_semaphore.as_ref().poll()
.expect("failed to perform a polling wait operation");
}
counting_semaphore.as_ref().poll()
.expect_err("unexpectedly succeeded to perform a polling wait operation");
for _ in 0..8 {
counting_semaphore.as_ref().signal()
.expect("failed to perform a signal operation");
}
counting_semaphore.as_ref().signal()
.expect_err("unexpectedly succeeded to perform a signal operation");
Consume and “leak” self
, returning a reference SemaphoreRef<'a>
.
Get the raw object ID as abi::NonNullID
.
Borrow Semaphore
as SemaphoreRef
.
Use this to perform operations on semaphores because most of the
methods are implemented on SemaphoreRef
but not Semaphore
.