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

sync: Implement map methods of parking_lot fame #2445

Merged
merged 1 commit into from Aug 26, 2020

Commits on Aug 16, 2020

  1. sync: Implement map methods of parking_lot fame

    Generally, this mimics the way `MappedRwLock*Guard`s are implemented in
    `parking_lot`. By storing a raw pointer in the guards themselves
    referencing the mapped data and maintaining type invariants through
    `PhantomData`. I didn't try to think too much about this, so if someone
    has objections I'd love to hear them.
    
    I've also dropped the internal use of `ReleasingPermit`, since it made
    the guards unecessarily large. The number of permits that need to be
    released are already known by the guards themselves, and is instead
    governed directly in the relevant `Drop` impls.  This has the benefit of
    making the guards as small as possible, for the non-mapped variants this
    means a single reference is enough.
    
    `fmt::Debug` impls have been adjusted to behave exactly like the
    delegating impls in `parking_lot`. `fmt::Display` impls have been added
    for all guard types which behave the same. This does change the format
    of debug impls, for which I'm not sure if we provide any guarantees.
    udoprog committed Aug 16, 2020
    Copy the full SHA
    d2631ca View commit details
    Browse the repository at this point in the history