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
14 pub const fn new() -> Mutex
{
15 Mutex { locked: Cell::new(false) }
19 pub unsafe fn init(&mut self) {}
22 pub unsafe fn lock(&self) {
23 assert_eq
!(self.locked
.replace(true), false, "cannot recursively acquire mutex");
27 pub unsafe fn unlock(&self) {
28 self.locked
.set(false);
32 pub unsafe fn try_lock(&self) -> bool
{
33 self.locked
.replace(true) == false
37 pub unsafe fn destroy(&self) {}
40 // All empty stubs because this platform does not yet support threads, so lock
41 // acquisition always succeeds.
42 pub struct ReentrantMutex {}
45 pub const unsafe fn uninitialized() -> ReentrantMutex
{
49 pub unsafe fn init(&self) {}
51 pub unsafe fn lock(&self) {}
54 pub unsafe fn try_lock(&self) -> bool
{
58 pub unsafe fn unlock(&self) {}
60 pub unsafe fn destroy(&self) {}