Skip to main content

acquire_write

Function acquire_write 

Source
pub fn acquire_write<'a, T>(
    lock: &'a RwLock<T>,
    lock_name: &'static str,
) -> Result<RwLockWriteGuard<'a, T>, LockPoisonedError>
Expand description

Acquires a write lock, returning an error if the lock is poisoned.

§Errors

Returns LockPoisonedError if another thread panicked while holding this lock.

§Examples

use std::sync::RwLock;
use uni_common::sync::acquire_write;

let lock = RwLock::new(42);
let mut guard = acquire_write(&lock, "my_data").unwrap();
*guard = 100;