#lock #order #locking #compile-time #deadlock #no-alloc

no-std lock_ordering

Lock ordering enforcement at compile time

1 unstable release

0.1.0 Oct 9, 2023

#271 in No standard library

MIT license

8KB
145 lines

Lock ordering enforcement at compile time

This library contains types and traits to ensure, at compile time, that locks are acquired in the correct order.

Credits

Inspired by Fuchsia's lock-ordering and lock-sequence libraries.


lib.rs:

Lock ordering enforcement at compile time

This library contains types and traits to ensure that locks that are held at the same time are acquired in the correct order. This lets code authors verify, at compile time, that their code is free of deadlock opportunities.

The way this works is by using traits in the [relation] crate to define orderings between marker types that represent different lock-levels. The core logic lives in the LockedAt type; it uses trait bounds to ensure that any acquisition of locks respects these orderings.

No runtime deps