MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / with_file_lock

Function with_file_lock

crates/opencode-tool/src/tool.rs:25–41  ·  view source on GitHub ↗
(filepath: &str, f: F)

Source from the content-addressed store, hash-verified

23}
24
25pub async fn with_file_lock<F, Fut, T>(filepath: &str, f: F) -> T
26where
27 F: FnOnce() -> Fut,
28 Fut: Future<Output = T>,
29{
30 let lock = {
31 let locks = get_file_locks();
32 let mut locks_guard = locks.lock().unwrap();
33 locks_guard
34 .entry(filepath.to_string())
35 .or_insert_with(|| Arc::new(Mutex::new(())))
36 .clone()
37 };
38
39 let _guard = lock.lock().await;
40 f().await
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct QuestionDef {

Callers 1

executeMethod · 0.85

Calls 3

get_file_locksFunction · 0.85
newFunction · 0.85
cloneMethod · 0.45

Tested by

no test coverage detected