[−][src]Struct semalock::Semalock
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.
pub fn unlink(self) -> Result<(), SemalockError>
[src]
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]
A: FnOnce(&mut Self) -> B,
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]
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,
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,