Skip to content

Implement downgrading for RwLock #32527

Closed
@Yoric

Description

@Yoric

Some implementations of RwLock implement a downgrading primitive that makes it possible to atomically release a write and enter a read, without letting any other writer grab the lock in the meantime.

This is sometimes very useful, so I'd like some such feature for RwLock.

For instance:

struct RwLockWriteGuard<'a, T> {
  // ...
}

/// Drop the write lock in favor of a read lock, atomically.
///
/// Returns an error if, for some reason, the lock cannot be reacquired, in which case the lock is only dropped.
fn downgrade(self) -> LockResult<RwLockReadGuard<'a, T>> {
  // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions