Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grype/pharo-rwmutex
Mutual Exclusion access to a shared resource between a single writer and multiple concurrent readers.
https://github.com/grype/pharo-rwmutex
concurrency concurrent-programming mutex mutex-synchronisation pharo pharo-smalltalk rwmutex
Last synced: 8 days ago
JSON representation
Mutual Exclusion access to a shared resource between a single writer and multiple concurrent readers.
- Host: GitHub
- URL: https://github.com/grype/pharo-rwmutex
- Owner: grype
- License: mit
- Created: 2020-01-08T08:44:11.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-02T06:24:58.000Z (almost 5 years ago)
- Last Synced: 2024-12-18T21:17:31.155Z (8 days ago)
- Topics: concurrency, concurrent-programming, mutex, mutex-synchronisation, pharo, pharo-smalltalk, rwmutex
- Language: Smalltalk
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pharo-RWMutex
Mutual Exclusion access to a shared resource between a single writer and multiple concurrent readers.I am like **Mutex** that protects write access to a shared resource while granting read access to multiple requestors. Read and write access is mutually exclusive. That is, a write request will block new read requests and wait on existing read-critical processes to finish. Concurrent read requests will be granted until write access is requested.
### Example:
```smalltalk
mutex := RWMutex new.
[ mutex readCritical: [ ... ] ] fork.
[ mutex readCritical: [ ... ] ] fork.
[ mutex writeCritical: [ ... ] ] fork.
[ mutex writeCritical: [ ... ] ] fork.
[ mutex readCritical: [ ... ] ] fork.
```The first forked process will lock write access. The second forked process will take place concurrently with the first. The third forked process will wait for the first two to complete before entering a critical write section, where subsequent write requests, such as the fourth forked process, will wait on it. The final forked process will take place after all of the other process had concluded.
# Installation
```smalltalk
Metacello new
repository: 'github://grype/Pharo-RWMutex';
baseline: 'RWMutex';
load.
```