[][src]Struct heliograph::Semaphore

pub struct Semaphore { /* fields omitted */ }

A System V semaphore set

Implementations

impl Semaphore[src]

pub fn create(
    key: Key,
    nsems: usize,
    exclusive: Exclusive,
    mode: Mode
) -> Result<Semaphore>
[src]

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 semth 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

impl Debug for Semaphore[src]

impl Drop for Semaphore[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.