@@ -67,6 +67,7 @@ impl Mutex {
67
67
#[ inline]
68
68
pub unsafe fn init ( & mut self ) { }
69
69
pub unsafe fn lock ( & self ) {
70
+ // SAFETY: The caller must ensure that the mutex is not moved or copied
70
71
unsafe {
71
72
match kind ( ) {
72
73
Kind :: SRWLock => c:: AcquireSRWLockExclusive ( raw ( self ) ) ,
@@ -83,6 +84,7 @@ impl Mutex {
83
84
}
84
85
}
85
86
pub unsafe fn try_lock ( & self ) -> bool {
87
+ // SAFETY: The caller must ensure that the mutex is not moved or copied
86
88
unsafe {
87
89
match kind ( ) {
88
90
Kind :: SRWLock => c:: TryAcquireSRWLockExclusive ( raw ( self ) ) != 0 ,
@@ -102,6 +104,7 @@ impl Mutex {
102
104
}
103
105
}
104
106
pub unsafe fn unlock ( & self ) {
107
+ // SAFETY: The caller must ensure that the mutex is not moved or copied
105
108
unsafe {
106
109
match kind ( ) {
107
110
Kind :: SRWLock => c:: ReleaseSRWLockExclusive ( raw ( self ) ) ,
@@ -114,6 +117,7 @@ impl Mutex {
114
117
}
115
118
}
116
119
pub unsafe fn destroy ( & self ) {
120
+ // SAFETY: The caller must ensure that the mutex is not moved or copied
117
121
unsafe {
118
122
match kind ( ) {
119
123
Kind :: SRWLock => { }
@@ -134,8 +138,10 @@ impl Mutex {
134
138
unsafe {
135
139
inner. remutex . init ( ) ;
136
140
}
137
- let inner = Box :: into_raw ( inner) ;
138
-
141
+ }
142
+
143
+ unsafe fn flag_locked ( & self ) -> bool {
144
+ // SAFETY: The caller must ensure that the mutex is not moved or copied
139
145
unsafe {
140
146
match self . lock . compare_and_swap ( 0 , inner as usize , Ordering :: SeqCst ) {
141
147
0 => inner,
0 commit comments