#rw-lock #refcell #async #rwlock #concurrency #mult-threading

bin+lib manual_rwlock

A library implementing An RW lock with more manual control

7 unstable releases (3 breaking)

0.4.0 Jul 6, 2024
0.3.0 Jun 29, 2024
0.2.0 Jun 29, 2024
0.1.3 Jun 29, 2024

#24 in #rw-lock

Download history 329/week @ 2024-06-26 137/week @ 2024-07-03 9/week @ 2024-07-10 14/week @ 2024-07-24 6/week @ 2024-07-31

335 downloads per month

MIT license

24KB
467 lines

Manual RwLock

A library implementing An RW lock with more manual control Sorry for poor documentation, I will update this later.
New read write lock struct: [MrwLock]

Examples

Convert between Guards

use manual_rwlock::MrwLock;
let mrw_lock = MrwLock::new(10);
let read = mrw_lock.read().unwrap();
let mut write = read.to_write().unwrap();
*write = 5;
let read = write.to_read();
assert_eq!(*read, 5)

Release and Reobtain locks

use manual_rwlock::MrwLock;
let mrw_lock = MrwLock::new(10);
let read = mrw_lock.read().unwrap();
unsafe {read.early_release();}
{
    let mut write = mrw_lock.write().unwrap();
    *write = 5;
}
unsafe {read.reobtain();}
assert_eq!(*read, 5)

Clone [ReadGaurd]

 use manual_rwlock::MrwLock;

let rwlock = MrwLock::new(5);
let read = rwlock.read().unwrap();
let read2 = read.clone();
assert_eq!(*read2, 5);

Use Locking Directly

[LockState]

Dependencies

~0–10MB
~43K SLoC