[][src]Struct semalock::Semalock

pub struct Semalock {
    pub file: File,
    // some fields omitted
}

Fields

file: File

Methods

impl Semalock[src]

pub fn new(path: &Path) -> Result<Semalock, SemalockError>[src]

Creates a new Semalock, opening or creating the file for reading and writing. A POSIX named semaphore is allocated (based on the hash of the path) and is used to reduce contention when acquiring exclusive file locks. On Linux, this is nearly FIFO in terms of acquiring the lock, though not always. Good (i.e. very minimal CPU usage) performance has been tested with upto 8192 simultaneous writers.

Unlinks the semaphore used by this Semalock instance. Future acquisitions will result in a new kernel object being created. This does not affect the data of the file that this lock is protecting. See POSIX sem_unlink for more details.

pub fn with<A, B>(&mut self, a: A) -> Result<B, SemalockError> where
    A: FnOnce(&mut Self) -> B, 
[src]

Acquires the lock, runs the provided function, and releases the lock. If the provided function panics, the lock is not automatically released. In this case, the secondary level of exclusive file locks will take effect, temporarily affecting performance until a timeout occurs and normal behavior is restored (in other applications).

Auto Trait Implementations

impl RefUnwindSafe for Semalock

impl !Send for Semalock

impl !Sync for Semalock

impl Unpin for Semalock

impl UnwindSafe for Semalock

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,