#lock #shared #store #guard #thread #synchronously #lock-store

sero

A simple and lightweight library for maintaining a shared store of locks

18 releases

0.1.17 Dec 24, 2022
0.1.16 Dec 24, 2022

#531 in Concurrency

Download history 8/week @ 2024-02-26 317/week @ 2024-03-11 163/week @ 2024-04-01

480 downloads per month
Used in ceiling

MIT license

13KB
232 lines

sero

Sero is a simple and lightweight library for maintaining a shared store of locks.

Usage

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 is a simple and lightweight library for maintaining a shared store of locks.

Usage

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

Dependencies

~1–7MB
~20K SLoC