Skip to main content

lock

Macro lock 

Source
macro_rules! lock {
    (let mut $guard:ident = $lock_init:expr) => { ... };
    (let $guard:ident = $lock_init:expr) => { ... };
    ($lock_init:expr) => { ... };
}
Expand description

Locks a mutex.

Usage: ksync::lock!(let mut guard = self.lock_mu()); Locks the mutex and binds a mutable pin to guard. Useful when you need to mutate guarded fields via guard.as_mut().fields_mut().

ksync::lock!(let guard = self.lock_mu()); Locks the mutex and binds an immutable pin to guard. Useful for read-only access to guarded fields via guard.fields().

ksync::lock!(self.lock_mu()); Locks the mutex and keeps it locked until the end of the scope, without binding the guard.