A same-thread alias of this held lock (CB-8B): the alias shares the underlying OS lock and increments the nesting count, so a nested executor can hold its own guard under the caller's boundary without a second flock. Dropping the alias only decrements the count.
(&self)
| 98 | /// executor can hold its own guard under the caller's boundary without |
| 99 | /// a second flock. Dropping the alias only decrements the count. |
| 100 | fn alias(&self) -> Self { |
| 101 | HELD_LOCKS.with(|held| { |
| 102 | let mut held = held.borrow_mut(); |
| 103 | match held.get_mut(&self.path) { |
| 104 | Some((count, _, _)) => *count += 1, |
| 105 | None => { |
| 106 | // The outer guard always has a HELD_LOCKS entry; a |
| 107 | // missing entry means the alias is outliving its |
| 108 | // boundary, which the caller must never do. |
| 109 | let entry = |
| 110 | held.entry(self.path.clone()) |
| 111 | .or_insert((0usize, Weak::new(), false)); |
| 112 | entry.0 += 1; |
| 113 | } |
| 114 | } |
| 115 | }); |
| 116 | Self { |
| 117 | file: Arc::clone(&self.file), |
| 118 | path: self.path.clone(), |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | impl Drop for AdvisoryFileLock { |
no test coverage detected