https://github.com/invenia/readwritelocks.jl
A simple read-write lock for Julia
https://github.com/invenia/readwritelocks.jl
concurrency julia locking threading
Last synced: 7 months ago
JSON representation
A simple read-write lock for Julia
- Host: GitHub
- URL: https://github.com/invenia/readwritelocks.jl
- Owner: invenia
- License: other
- Created: 2015-10-22T19:29:35.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-04-26T16:21:19.000Z (about 3 years ago)
- Last Synced: 2025-04-06T18:39:41.186Z (about 1 year ago)
- Topics: concurrency, julia, locking, threading
- Language: Julia
- Size: 22.5 KB
- Stars: 5
- Watchers: 2
- Forks: 7
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ReadWriteLocks
[](https://github.com/Invenia/ReadWriteLocks.jl/actions?query=workflow%3ACI)
[](https://codecov.io/github/invenia/ReadWriteLocks.jl?branch=master)
## Usage
```julia
using ReadWriteLocks
# The type provided by this package is ReadWriteLock.
# It has a single constructor.
rwlock = ReadWriteLock()
# This lock provides access to a read lock and a write lock
rlock = read_lock(rwlock)
wlock = write_lock(rwlock)
# To acquire a read lock:
lock!(rlock)
# To release a read lock:
unlock!(rlock)
#=
Write locks provide the same interface.
You can acquire any number of read locks at a time.
A read lock will block if a write lock has been acquired.
A write lock will block if a read lock or write lock has been acquired.
=#
```
## Compatibility
This package is meant to be compatible with Julia's lightweight threads (where it is not strictly necessary) and true multithreaded Julia, in order to facilitate unified codebases that support future thread-safety.
## License
ReadWriteLocks.jl is provided under the MIT "Expat" License.
## Citation
This is a reimplementation of the original Java source from:
> M. Herlihy and N. Shavit, “8.3.1 Simple Readers-Writers Lock,” in The art of multiprocessor programming, revised first edition, Rev. 1st., Waltham, Massachusetts: Morgan Kaufmann, 2012, pp. 184–185.