4 // This platform has no threads, so we can use a Cell here.
8 pub type MovableRWLock = RWLock;
10 unsafe impl Send for RWLock {}
11 unsafe impl Sync for RWLock {} // no threads on this platform
14 pub const fn new() -> RWLock {
15 RWLock { mode: Cell::new(0) }
19 pub unsafe fn read(&self) {
20 let m = self.mode.get();
24 rtabort!("rwlock locked for writing");
29 pub unsafe fn try_read(&self) -> bool {
30 let m = self.mode.get();
40 pub unsafe fn write(&self) {
41 if self.mode.replace(-1) != 0 {
42 rtabort!("rwlock locked for reading")
47 pub unsafe fn try_write(&self) -> bool {
48 if self.mode.get() == 0 {
57 pub unsafe fn read_unlock(&self) {
58 self.mode.set(self.mode.get() - 1);
62 pub unsafe fn write_unlock(&self) {
63 assert_eq!(self.mode.replace(0), -1);
67 pub unsafe fn destroy(&self) {}