forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add downlevel implementations for Mutex, CondVar and RwLock
Because of the movability and const-initialization requirements, the implementation uses LazyBox. OnceLock cannot be used here as it needs a thread parker. The windows-specific thread parker is XP+ only, and the generic thread parker is implemented in tems of a condvar, which would make this a circular dependency. - Fall back to critical sections on NT4+, and `CreateMutex` objects for everything else. OnceLock is used to do the necessary initialization for these fallback implementations. - Implement `RwLock` fallback by dropping down to a `Mutex`. - Implement `CondVar` fallback based on `CreateEventA`/`PulseEvent`. This should be used with extreme caution as it may cause deadlocks. See which may cause deadlocks. See [Old New Thing](https://devblogs.microsoft.com/oldnewthing/20050105-00/?p=36803) and the [MSDN docs](https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-pulseevent) for more information.
- Loading branch information
Showing
12 changed files
with
660 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.