semafy
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

Semafy

Semafy provides synchronization primitives based on concepts from C++ standard threading and synchronization libraries. It includes support for mutexes, condition variables, semaphores, and shared mutexes to facilitate robust concurrent applications in environments supporting shared memory and atomic operations.

Version Maintenance License codecov npm bundle size

Features

  • Mutex: Provides exclusive locking to protect shared data from concurrent access.
  • ConditionVariable: Allows agents (main thread, web workers) to wait for certain conditions to occur.
  • RecursiveMutex: Provides exclusive, recursive locking to protect shared data from concurrent access.
  • Semaphore: Implements a semaphore to control access to a finite number of resources.
  • SharedMutex: Allows multiple readers or exclusive writer access, facilitating reader-writer scenarios.
  • Error Handling: Includes specific error classes like MutexError, MutexOwnershipError, MutexRelockError, and TimeoutError to handle different synchronization scenarios.

Installation

NPM:

npm install semafy

Yarn:

yarn add semafy

Browser Usage

For security reasons, browsers have certain requirements for using shared memory. These requirements must be met to use this library in a browser. Please see SharedArrayBuffer > Security Requirements for details.

Contributing

Contributions are welcome! Please submit any bugs, issues, or pull requests to the project's GitHub repository.

Package Sidebar

Install

npm i semafy

Weekly Downloads

9

Version

2.0.1

License

MIT

Unpacked Size

421 kB

Total Files

9

Last publish

Collaborators

  • havelessbemore