Soft fork: TryLock with Portable Atomics
This repository and the crate try-lock-portable-atomics is a soft fork of the try-lock crate.
This fork only applies PR #11 and the necessary metadata changes; otherwise, it tracks upstream 1:1.
Original README below.
TryLock
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.
Example
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!;