#lock #shared #store #guard #thread #asynchronous #lock-store

sero

一个简单且轻量级的库,用于维护锁的共享存储

18 个版本

0.1.17 2022年12月24日
0.1.16 2022年12月24日

#999 in 并发


用于 ceiling

MIT 许可证

13KB
232

sero

sero 是一个简单且轻量级的库,用于维护锁的共享存储。

用法

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);

lib.rs:

sero 是一个简单且轻量级的库,用于维护锁的共享存储。

用法

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);

依赖项

~0.9–6MB
~20K SLoC