mirror of
https://github.com/Noratrieb/pythonic_global_lock.git
synced 2026-01-14 16:25:02 +01:00
awesomeness
This commit is contained in:
parent
860c44707a
commit
695bac4e12
2 changed files with 24 additions and 8 deletions
18
README.md
Normal file
18
README.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# 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.
|
||||
|
||||
```rust
|
||||
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
|
||||
}
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue