Crates.io | sero |
lib.rs | sero |
version | 0.1.17 |
source | src |
created_at | 2022-12-20 03:42:17.702068 |
updated_at | 2022-12-24 02:30:00.379318 |
description | A simple and lightweight library for maintaining a shared store of locks. |
homepage | |
repository | https://github.com/mrvillage/sero |
max_upload_size | |
id | 741927 |
size | 18,804 |
Sero is a simple and lightweight library for maintaining a shared store of locks.
use sero::LockStore;
let store = LockStore::new();
// to lock asynchronously use
let guard = store.lock("key").await;
// to lock synchronously use
let guard = store.lock("key").wait();
// NOTE: synchronously locking will "park" the current thread until the lock is acquired
// locks are released when the LockGuard is dropped
// either with the drop function or when they go out of scope
drop(guard);