Struct wiggle::borrow::BorrowChecker
source · pub struct BorrowChecker { /* private fields */ }
Expand description
A simple borrow checker to implement the API guarantees of Wiggle.
This is not a generalized borrow checker and is coarse-grained where it
doesn’t actually take any regions into account. Instead it only tracks
whether there are temporally any shared/mutable borrows. This is
more-or-less a poor-man’s RefCell<T>
.
Note that this uses &AtomicU32
because this is passed around as
&BorrowChecker
in all GuestPtr
structures. This needs to be mutated
which might look like it needs Cell<u32>
, but &Cell<u32>
isn’t Sync
and we want futures with &BorrowChecker
to be Sync
, so this is an atomic
instead. Only one of these is created per-invocation though and it’s not
actually shared across threads, so mutations here are not done with
compare-and-swap but instead just loads/stores.