Skip to content

Commit

Permalink
sync: implement map methods of parking_lot fame (#2771)
Browse files Browse the repository at this point in the history

* 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.
  • Loading branch information
udoprog authored Aug 27, 2020
1 parent 30d4ec0 commit f0328f7
Show file tree
Hide file tree
Showing 2 changed files with 298 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
on:
push:
branches: ["master"]
branches: ["v0.2.x"]
pull_request:
branches: ["master"]
branches: ["v0.2.x"]

name: CI

Expand Down
Loading

0 comments on commit f0328f7

Please sign in to comment.