MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / alias

Method alias

atomic-repository/src/repository/locks.rs:100–120  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
123impl Drop for AdvisoryFileLock {

Callers 3

common_aliasMethod · 0.80

Calls 2

get_mutMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected