4 // This platform has no threads, so we can use a Cell here.
8 unsafe impl Send
for Mutex {}
9 unsafe impl Sync
for Mutex {}
// no threads on this platform
13 #[rustc_const_stable(feature = "const_locks", since = "1.63.0")]
14 pub const fn new() -> Mutex
{
15 Mutex { locked: Cell::new(false) }
20 assert_eq
!(self.locked
.replace(true), false, "cannot recursively acquire mutex");
24 pub unsafe fn unlock(&self) {
25 self.locked
.set(false);
29 pub fn try_lock(&self) -> bool
{
30 self.locked
.replace(true) == false