Crates.io | pythonic_global_lock |
lib.rs | pythonic_global_lock |
version | 0.1.0 |
source | src |
created_at | 2022-01-25 08:22:16.353445 |
updated_at | 2022-01-25 08:22:16.353445 |
description | A globally locked mutex |
homepage | |
repository | https://github.com/Nilstrieb/pythonic_global_lock |
max_upload_size | |
id | 520652 |
size | 4,481 |
This crate provides a GLock<T>
, that is globally locked. Every GLock<T>
uses the same global lock, so locking on
will lock all. Sounds like a dumb idea? One of the most popular programming implementations does it, so it must be
smart.
fn main() {
let lock1 = pythonic_global_lock::GLock::new(1);
let lock2 = pythonic_global_lock::GLock::new(2);
{
let locked1 = lock1.lock();
println!("{}", &*locked1)
// locking lock2 here would be a deadlock
}
}