Skip to content

Protecting multiple objects with one lock #479

@mahkoh

Description

@mahkoh

I have the following requirements:

  1. I have multiple objects connected via Arc and interior mutability.
  2. These objects contain mutable data.
  3. I want all of that data to be protected by a single lock.
  4. It is ok if the lock only hands out immutable references as long as it maps Send to Sync like ReentrantLock. I can then use cheap, non-Sync interior mutability for the actual mutations.

I've implemented this here on top of the parking_lot RawMutex: https://docs.rs/shared-lock

Do you think it makes sense to support this pattern in parking_lot directly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions