Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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.
```