New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

read-write-lock

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-write-lock

Reads are exclusive with writes, writes are exclusive with everything

latest
Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
23
76.92%
Maintainers
1
Weekly downloads
 
Created
Source

read-write-lock

Build Status

  • a write lock prevents all other writes or reads
  • a read lock only prevents writes

Based on mutexify!

Algorithm

Write lock requests get put on the queue and handed out in order.

Read lock requests get put on the queue too - but when one read lock is given, all read requests in the queue go at once - once they all come back, it's on to the next lock request in the queue.

Usage

var createMutex = require('read-write-lock')

var mutex = createMutex()

mutex.writeLock(function(release) {
	// lol I've got a write lock which means that nobody else can do anything

	setTimeout(release, 200)
})

mutex.readLock(function(release) {
	// I've got a read lock at the same time as the function below!
	setTimeout(release, 100)
})

mutex.readLock(function(release) {
	// I've got a read lock at the same time as the function above!
	setTimeout(release, 200)
})

License

WTFPL

Keywords

mutex

FAQs

Package last updated on 17 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts