MCPcopy Index your code
hub / github.com/AI45Lab/Code / write_or_recover

Function write_or_recover

core/src/error.rs:103–107  ·  view source on GitHub ↗

Acquire a write guard, recovering from poison if the lock was poisoned. See [`read_or_recover`] for rationale.

(
    lock: &std::sync::RwLock<T>,
)

Source from the content-addressed store, hash-verified

101///
102/// See [`read_or_recover`] for rationale.
103pub(crate) fn write_or_recover<T>(
104 lock: &std::sync::RwLock<T>,
105) -> std::sync::RwLockWriteGuard<'_, T> {
106 lock.write().unwrap_or_else(|p| p.into_inner())
107}
108
109#[cfg(test)]
110mod tests {

Callers 15

registerMethod · 0.85
unregisterMethod · 0.85
save_snapshotMethod · 0.85
recordMethod · 0.85
record_resultMethod · 0.85
observe_agent_eventMethod · 0.85
clear_runtime_actionsMethod · 0.85

Calls 1

writeMethod · 0.80

Tested by 2