[−][src]Struct heliograph::Semaphore
A System V semaphore set
Implementations
impl Semaphore
[src]
pub fn create(
key: Key,
nsems: usize,
exclusive: Exclusive,
mode: Mode
) -> Result<Semaphore>
[src]
key: Key,
nsems: usize,
exclusive: Exclusive,
mode: Mode
) -> Result<Semaphore>
Create a new semaphore set if it does not exist yet
The semaphore set will be created with nsems
semaphores and
the key key
. This operation will fail if exclusive
is set
to Yes
and the semaphore with this key
already exists.
Finally, mode
is used to define the permissions set on the
semaphore; typical usage will be u=rwx,go=
.
Note if you want to open as exclusive, in some yet unknown
circumstances (probably linked to a ftok
hash collision),
Linux claims that the semaphore already exists.
So if you plan on opening an exclusive semaphore, you probably
should do so in a loop that tests different values for the
NonZeroU8
passed to Key::new
.
See also man 2 semget
.
pub fn open(key: Key, nsems: usize) -> Result<Semaphore>
[src]
Open a pre-existing semaphore set
The semaphore set opened will be the one with key key
and
nsems
semaphores.
pub fn try_clone(&self) -> Result<Semaphore>
[src]
Clone a semaphore set
pub fn op(&self, ops: &[SemOp]) -> Result<()>
[src]
Execute a semaphore set operation
This will take all the operations in ops
, and apply them
atomically on the semaphore set, while making sure no
semaphore value goes under zero.
See also man 2 semop
pub fn get_val(&self, sem: usize) -> Result<c_int>
[src]
Retrieves the current value of the sem
th semaphore in the
current set
pub fn get_all(&self) -> Result<Vec<c_ushort>>
[src]
pub fn set_val(&self, sem: usize, val: c_int) -> Result<()>
[src]
pub unsafe fn set_val_unchecked(&self, sem: c_int, val: c_int) -> Result<()>
[src]
See man 2 semctl
option SETVAL
Safety
The semaphore number must be strictly less than the number of semaphores passed in when creating the semaphore
pub fn at(&self, idx: c_ushort) -> Sem
[src]
Retrieve a semaphore on which to perform operations
Panics
Panics if idx
is greater than or equal to the number of
semaphores given when creating the semaphore
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Semaphore
[src]
impl Send for Semaphore
[src]
impl Sync for Semaphore
[src]
impl Unpin for Semaphore
[src]
impl UnwindSafe for Semaphore
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,