read-write-mutexify

Like mutexify but with read/write locks

MIT 3 个版本
安装
npm install read-write-mutexify
yarn add read-write-mutexify
pnpm add read-write-mutexify
bun add read-write-mutexify
README

read-write-mutexify

Like mutexify but with read/write locks

npm install read-write-mutexify

Usage

const RW = require('read-write-mutexify')

const rw = new RW()

// read locks waits for writer locks to be released
await rw.read.lock()
await rw.read.lock() // make as many as you want

// unlock with unlock
rw.read.unlock()
rw.read.unlock()

// only one writer can have the write lock and it waits
// for any read lock to be released

await rw.write.lock()

// unlock with unlock
rw.write.unlock()

License

MIT

版本列表
2.1.0 2023-06-04
2.0.0 2023-06-02
1.0.0 2023-06-02