A light-weight lock guarded by an atomic boolean.
Most efficient when contention is low, acquiring the lock is a single atomic swap, and releasing it just 1 more atomic swap.
use Arc; use TryLock; // a thing we want to share // lock it up! let widget1 = new; let widget2 = widget1.clone; // mutate the widget let mut locked = widget1.try_lock.expect; locked.name.push_str; // hands off, buddy let not_locked = widget2.try_lock; assert!; // ok, you can have it drop; let locked2 = widget2.try_lock.expect; assert_eq!;