#locking #mutex #joke

pythonic_global_lock

A globally locked mutex

1 unstable release

0.1.0 Jan 25, 2022

#36 in #joke

MIT license

4KB

pythonic_global_lock

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
    }
}

Dependencies

~465–780KB
~13K SLoC