#future #rwlock #mutex #wasm32 #synch

fut_rwlock

A read-write lock that is read and written via Futures

1 unstable release

0.1.0 Jul 31, 2021

#963 in Asynchronous

Apache-2.0

27KB
539 lines

Workflow Status Maintenance

fut_rwlock

fut_rwlock

FutRwLock returns a Future-wrapped locks to a read-write lock synchronization primitive. It is a wrapper around the std library synchronization primitive std::sync::RwLock.

  • The FutRwLock does not block the calling thread that requests a lock.
  • Any call to [read]FutRwLock::read/write returns an asynchronous Future that must be awaited even if it resolves immediately. If a lock isn't awaited, it does nothing.
  • To attempt to acquire an Option-wrapped read or write lock synchronously/immediately use the try_read_now or try_write_now. synchronous methods.
  • It was made to be suitable for use in single-threaded wasm environments without running into errors when the environment tries to block upon accessing a synchronization primitive.
  • Locks are alloted to callers in request order.

License: Apache-2.0

Dependencies

~1MB
~15K SLoC