forked from elarivie/pyReaderWriterLock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,32 +3,48 @@ Reader Writer Lock | |
|
||
**A python implementation of the three Reader-Writer problems.** | ||
|
||
[![Code size in bytes](https://img.shields.io/github/languages/code-size/elarivie/pyReaderWriterLock.svg)][pyReaderWriterLock_repo] | ||
[![Build Status](https://travis-ci.org/elarivie/pyReaderWriterLock.svg?branch=master)](https://travis-ci.org/elarivie/pyReaderWriterLock) | ||
[![BugTracker](https://img.shields.io/github/issues/elarivie/pyReaderWriterLock.svg)][pyReaderWriterLock_BugTracker] | ||
![License](https://img.shields.io/pypi/l/readerwriterlock.svg) | ||
|
||
[![Python Version](https://img.shields.io/pypi/pyversions/readerwriterlock.svg)][python] | ||
[![Pypi Version](https://img.shields.io/pypi/v/readerwriterlock.svg)][pyReaderWriterLock_Pypi] | ||
[![Pypi Status](https://img.shields.io/pypi/status/readerwriterlock.svg)][pyReaderWriterLock_Pypi] | ||
|
||
Not only does it implement the reader-writer problems, it is also compliant with the python lock interface which includes support for timeouts. | ||
|
||
For reading about the theory behind the reader-writer problems refer to [Wikipedia](https://wikipedia.org/wiki/Readers–writers_problem). | ||
|
||
# Installation | ||
|
||
Install the python package [readerwriterlock](https://pypi.python.org/pypi/readerwriterlock) | ||
|
||
python3 -m pip install readerwriterlock | ||
|
||
|
||
# Usage | ||
|
||
Initialize a new lock base on your access priority need which is going to be use by the threads: | ||
|
||
**Reader priority** (*aka First readers-writers problem*) | ||
|
||
```python | ||
import rwlock | ||
from readerwriterlock import rwlock | ||
a = rwlock.RWLockRead() | ||
``` | ||
|
||
**Writer priority** (*aka Second readers-writers problem*) | ||
|
||
```python | ||
import rwlock | ||
from readerwriterlock import rwlock | ||
a = rwlock.RWLockWrite() | ||
``` | ||
|
||
**Fair priority** (*aka Third readers-writers problem*) | ||
|
||
```python | ||
import rwlock | ||
from readerwriterlock import rwlock | ||
a = rwlock.RWLockFair() | ||
``` | ||
|
||
|
@@ -73,3 +89,9 @@ Contact | |
---- | ||
* Project: [GitHub](https://github.com/elarivie/pyReaderWriterLock) | ||
* Éric Larivière <[email protected]> | ||
|
||
[python]: https://www.python.org | ||
[pyReaderWriterLock_repo]: https://github.com/elarivie/pyReaderWriterLock | ||
[pyReaderWriterLock_package]: https://atom.io/packages/pyReaderWriterLock | ||
[pyReaderWriterLock_BugTracker]: https://github.com/elarivie/pyReaderWriterLock/issues | ||
[pyReaderWriterLock_Pypi]: https://github.com/elarivie/pyReaderWriterLock/issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters