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

feat(maitake): add maitake::sync::RwLock #307

Merged
merged 4 commits into from
Sep 1, 2022
Merged

feat(maitake): add maitake::sync::RwLock #307

merged 4 commits into from
Sep 1, 2022

Conversation

hawkw
Copy link
Owner

@hawkw hawkw commented Sep 1, 2022

This branch adds an async read-write lock implementation in
maitake::sync. This lock is implemented using the Semaphore type
added in #301. The rwlock is modeled using a Semaphore with
Semaphore::MAX_PERMITS permits in it; a reader must acquire a single
permit to gain read access, while a writer must acquire all the permits.

This branch adds an async read-write lock implementation in
`maitake::sync`. This lock is implemented using the `Semaphore` type
added in #301. The rwlock is modeled using a `Semaphore` with
`Semaphore::MAX_PERMITS` permits in it; a reader must acquire a single
permit to gain read access, while a writer must acquire all the permits.
@hawkw hawkw merged commit 1b8c7a4 into main Sep 1, 2022
@hawkw hawkw deleted the eliza/rwlock branch September 1, 2022 20:50
hawkw added a commit that referenced this pull request Sep 2, 2022
This branch builds on the `maitake::sync::RwLock` type added in #307 by
adding `OwnedRwLockReadGuard` and `OwnedRwLockWriteGuard` types and
`read_owned`/`write_owned`/`try_read_owned`/`try_write_owned` methods to
`RwLock`, similar to the `lock_owned`/`OwnedMutexGuard` API for
`maitake::sync::Mutex`. Unlike the `RwLock{Read, Write}Guard` types,
which borrow a reference to the lock, the `Owned{Read, Write}Guard`
types hold an `Arc` clone of the `RwLock` and are therefore valid for
the `'static` lifetime.

These methods are available when the `RwLock` is wrapped in an `Arc`,
and therefore require `maitake`'s "alloc" feature flag to be enabled.
hawkw added a commit that referenced this pull request Sep 3, 2022
This branch builds on the `maitake::sync::RwLock` type added in #307 by
adding `OwnedRwLockReadGuard` and `OwnedRwLockWriteGuard` types and
`read_owned`/`write_owned`/`try_read_owned`/`try_write_owned` methods to
`RwLock`, similar to the `lock_owned`/`OwnedMutexGuard` API for
`maitake::sync::Mutex`. Unlike the `RwLock{Read, Write}Guard` types,
which borrow a reference to the lock, the `Owned{Read, Write}Guard`
types hold an `Arc` clone of the `RwLock` and are therefore valid for
the `'static` lifetime.

These methods are available when the `RwLock` is wrapped in an `Arc`,
and therefore require `maitake`'s "alloc" feature flag to be enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant