pub struct CountSem { /* private fields */ }Expand description
A counting semaphore.
Implementations§
Source§impl CountSem
impl CountSem
Sourcepub fn new(name: &str, initial_value: u32) -> Result<Self>
pub fn new(name: &str, initial_value: u32) -> Result<Self>
Creates a new counting semaphore.
For portability, keep initial_value within short int
range (0–32767). Some RTOS impose upper limits.
§Arguments
name: A unique string to identify the semaphore.initial_value: The initial count of the semaphore.
Sourcepub fn take(&self) -> Result<()>
pub fn take(&self) -> Result<()>
Blocks until the semaphore’s count is non-zero, then decrements it.
Sourcepub fn timed_wait(&self, timeout_ms: u32) -> Result<()>
pub fn timed_wait(&self, timeout_ms: u32) -> Result<()>
Blocks until the semaphore can be taken, with a timeout.
§Arguments
timeout_ms: Timeout in milliseconds.
Sourcepub fn get_id_by_name(name: &str) -> Result<OsalId>
pub fn get_id_by_name(name: &str) -> Result<OsalId>
Finds an existing counting semaphore ID by its name.
Sourcepub fn get_info(&self) -> Result<CountSemProp>
pub fn get_info(&self) -> Result<CountSemProp>
Retrieves information about this counting semaphore.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CountSem
impl RefUnwindSafe for CountSem
impl Send for CountSem
impl Sync for CountSem
impl Unpin for CountSem
impl UnsafeUnpin for CountSem
impl UnwindSafe for CountSem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more