(&mut self)
| 122 | |
| 123 | impl Drop for AdvisoryFileLock { |
| 124 | fn drop(&mut self) { |
| 125 | let release = HELD_LOCKS.with(|held| { |
| 126 | let mut held = held.borrow_mut(); |
| 127 | match held.get_mut(&self.path) { |
| 128 | Some((count, _, _)) if *count > 1 => { |
| 129 | *count -= 1; |
| 130 | false |
| 131 | } |
| 132 | Some(_) => { |
| 133 | held.remove(&self.path); |
| 134 | true |
| 135 | } |
| 136 | None => false, |
| 137 | } |
| 138 | }); |
| 139 | if release { |
| 140 | let _ = FileExt::unlock(&*self.file); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | #[derive(Clone, Copy)] |