File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -556,10 +556,14 @@ impl<'a> PackageTask<'a> {
556556/// An RAII wrapper over a Win API named mutex
557557struct NamedMutex {
558558 handle : HANDLE ,
559+ // `ReleaseMutex` requires that it is called
560+ // only by threads that own the mutex handle.
561+ // Being `!Send` ensures that's always the case.
562+ _not_send : std:: marker:: PhantomData < * const ( ) > ,
559563}
560564
561565impl NamedMutex {
562- /// Acquire named mutex
566+ /// Acquires named mutex
563567 pub fn acquire ( name : & CStr ) -> Result < Self , WinError > {
564568 fn get_last_error ( ) -> WinError {
565569 // SAFETY: We have to just assume this function is safe to call
@@ -593,7 +597,7 @@ impl Drop for NamedMutex {
593597 // because this type itself created it and it
594598 // was never exposed outside
595599 unsafe {
596- // This Cannot fail as the calling thread is guaranteed
600+ // This cannot fail as the calling thread is guaranteed
597601 // to own the handle since we do not implement Send
598602 let _ = ReleaseMutex ( self . handle ) ;
599603
Original file line number Diff line number Diff line change @@ -191,10 +191,14 @@ where
191191/// An RAII wrapper over a Win API named mutex
192192pub struct NamedMutex {
193193 handle : HANDLE ,
194+ // `ReleaseMutex` requires that it is called
195+ // only by threads that own the mutex handle.
196+ // Being `!Send` ensures that's always the case.
197+ _not_send : std:: marker:: PhantomData < * const ( ) > ,
194198}
195199
196200impl NamedMutex {
197- /// Acquire named mutex
201+ /// Acquires named mutex
198202 pub fn acquire ( name : & CStr ) -> Result < Self , WinError > {
199203 fn get_last_error ( ) -> WinError {
200204 // SAFETY: We have to just assume this function is safe to call
@@ -228,7 +232,7 @@ impl Drop for NamedMutex {
228232 // because this type itself created it and it
229233 // was never exposed outside
230234 unsafe {
231- // This Cannot fail as the calling thread is guaranteed
235+ // This cannot fail as the calling thread is guaranteed
232236 // to own the handle since we do not implement Send
233237 let _ = ReleaseMutex ( self . handle ) ;
234238
You can’t perform that action at this time.
0 commit comments