Skip to content

Commit

Permalink
Usage guide.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamed2 committed Oct 23, 2015
1 parent 9ad35ee commit 4dc900b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@
[![Build status](https://ci.appveyor.com/api/projects/status/qxqgjon7ocblik3q?svg=true)](https://ci.appveyor.com/project/iamed2/readwritelocks-jl)
[![codecov.io](https://codecov.io/github/invenia/ReadWriteLocks.jl/coverage.svg?branch=master)](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.
Expand Down

0 comments on commit 4dc900b

Please sign in to comment.