pub struct NamedSemaphoreBuilder { /* private fields */ }Expand description
Builder for the NamedSemaphore.
§Example
§Create new named semaphore
ⓘ
use iceoryx2_bb_posix::semaphore::*;
use iceoryx2_bb_system_types::file_name::FileName;
use iceoryx2_bb_container::semantic_string::*;
let name = FileName::new(b"mySemaphoreName").unwrap();
let semaphore = NamedSemaphoreBuilder::new(&name)
// defines the clock which is used in [`SemaphoreInterface::timed_wait()`]
.clock_type(ClockType::Monotonic)
// the semaphore is created, if there already exists a semaphore it is deleted
.creation_mode(CreationMode::PurgeAndCreate)
.initial_value(5)
.permission(Permission::OWNER_ALL | Permission::GROUP_ALL)
.create()
.expect("failed to create semaphore");§Open existing semaphore
use iceoryx2_bb_posix::semaphore::*;
use iceoryx2_bb_system_types::file_name::FileName;
use iceoryx2_bb_container::semantic_string::*;
let name = FileName::new(b"mySemaphoreName").unwrap();
let semaphore = NamedSemaphoreBuilder::new(&name)
.clock_type(ClockType::Monotonic)
.open_existing()
.expect("failed to open semaphore");Implementations§
Source§impl NamedSemaphoreBuilder
impl NamedSemaphoreBuilder
pub fn new(name: &FileName) -> NamedSemaphoreBuilder
Sourcepub fn clock_type(self, value: ClockType) -> NamedSemaphoreBuilder
pub fn clock_type(self, value: ClockType) -> NamedSemaphoreBuilder
Sets the type of clock which will be used in SemaphoreInterface::timed_wait(). Be
aware a clock like ClockType::Realtime is depending on the systems local time. If this
time changes while waiting it can cause extrem long waits or no wait at all.
Sourcepub fn open_existing(
self,
) -> Result<NamedSemaphore, NamedSemaphoreCreationError>
pub fn open_existing( self, ) -> Result<NamedSemaphore, NamedSemaphoreCreationError>
Opens an already existing NamedSemaphore.
Sourcepub fn creation_mode(
self,
creation_mode: CreationMode,
) -> NamedSemaphoreCreationBuilder
pub fn creation_mode( self, creation_mode: CreationMode, ) -> NamedSemaphoreCreationBuilder
Defines how the semaphore will be created and returns the NamedSemaphoreCreationBuilder
which provides further means of configuration only available when a semaphore is created.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NamedSemaphoreBuilder
impl RefUnwindSafe for NamedSemaphoreBuilder
impl Send for NamedSemaphoreBuilder
impl Sync for NamedSemaphoreBuilder
impl Unpin for NamedSemaphoreBuilder
impl UnwindSafe for NamedSemaphoreBuilder
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