[−][src]Function simplelock::lock_until_finished
pub fn lock_until_finished<R: Any>(
lock: &mut impl Lock,
op: impl FnOnce() -> R + UnwindSafe
) -> SimpleLockResult<R>
Simple utility function for wrapping a closure with a lock. Since we use tempfile() behind the scenes, we can't reference a single file or a path. we instead ask for a directory, and any file in that directory means the lock is locked, otherwise we'll create a file which will either be cleaned up by close or via the OS if all handlers are closed.
Example
let result = lock_until_finished( &FakeLock::default(), || { // do something needing a lock. } );