Struct semalock::Semalock [] [src]

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

Fields

Methods

impl Semalock
[src]

[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.

[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).

Trait Implementations

Auto Trait Implementations

impl !Send for Semalock

impl !Sync for Semalock