4 // This platform has no threads, so we can use a Cell here.
8 pub type MovableMutex = Mutex;
10 unsafe impl Send for Mutex {}
11 unsafe impl Sync for Mutex {} // no threads on this platform
15 pub const fn new() -> Mutex {
16 Mutex { locked: Cell::new(false) }
20 pub unsafe fn lock(&self) {
21 assert_eq!(self.locked.replace(true), false, "cannot recursively acquire mutex");
25 pub unsafe fn unlock(&self) {
26 self.locked.set(false);
30 pub unsafe fn try_lock(&self) -> bool {
31 self.locked.replace(true) == false