#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

#23 in #rw-lock

Download history 6/week @ 2024-07-12 18/week @ 2024-07-26 2/week @ 2024-08-02 22/week @ 2024-09-13 11/week @ 2024-09-20 5/week @ 2024-09-27

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