Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read-Write Locks #735

Merged
merged 10 commits into from
Jul 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
document rwlocks
  • Loading branch information
vyzo committed Jul 22, 2023
commit 0adf7d3ec78e69ce2c2f1b2692088da14d539d93
69 changes: 69 additions & 0 deletions doc/reference/misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,75 @@ limit: 0/3
```
:::

## Read/Write Locks

The `:std/misc/rwlock` include an implementation of read write locks.

The implementation preempts readers when there are writers waiting, so
that no new readers will acquire the lock until all writers are done.

::: tip To use bindings from this module:
```scheme
(import :std/misc/rwlock)
```
:::

### make-rwlock
```scheme
(make-rwlock [name 'rwlock]) -> rwlock
```

Creates a (named) read-write lock.

### rwlock?
```scheme
(rwlock? obj) -> bool
```

Type predicate for rwlocks.

### rwlock-read-lock!
```scheme
(rwlock-read-lock! rwlock)
```

Acquires a read lock on `rwlock`; multiple readers can acquire the read lock simultaneously.

### rwlock-read-unlock!
```scheme
(rwlock-read-unlock! rwlock)
```

Releases a read lock on `rwlock`.

### rwlock-write-lock!
```scheme
(rwlock-write-lock! rwlock)
```

Acquires an exclusive write lock on `rwlock`.

### rwlock-write-unlock!
```scheme
(rwlock-write-unlock! rwlock)
```

Release an exclusive write lock on `rwlock`.

### with-read-lock
```scheme
(with-read-lock rwlock proc)
```

Evaluates `proc` while holding a read lock on `rwlock` and returns the result.

### with-write-lock
```scheme
(with-write-lock rwlock proc)
```

Evaluates `proc` while holding a write lock on `rwlock` and returns the result.


## Deques
::: tip To use the bindings from this module:
Expand Down