forked from gfx-rs/wgpu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Enforce a deadlock-free locking order for Mutexes.
If `debug_assertions` or the `"validate-locks"` feature are enabled, change `wgpu-core` to use a wrapper around `parking_lot::Mutex` that checks for potential deadlocks. At the moment, `wgpu-core` does contain deadlocks, so the ranking in the `lock::rank` module is incomplete, in the interests of keeping it acyclic. gfx-rs#5572 tracks the work needed to complete the ranking.
- Loading branch information
Showing
19 changed files
with
614 additions
and
82 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//! Instrumented lock types. | ||
//! | ||
//! This module defines a set of instrumented wrappers for the lock | ||
//! types used in `wgpu-core` ([`Mutex`], [`RwLock`], and | ||
//! [`SnatchLock`]) that help us understand and validate `wgpu-core` | ||
//! synchronization. | ||
//! | ||
//! - The [`ranked`] module defines lock types that perform run-time | ||
//! checks to ensure that each thread acquires locks only in a | ||
//! specific order, to prevent deadlocks. | ||
//! | ||
//! - The [`vanilla`] module defines lock types that are | ||
//! uninstrumented, no-overhead wrappers around the standard lock | ||
//! types. | ||
//! | ||
//! (We plan to add more wrappers in the future.) | ||
//! | ||
//! If the `validate-locks` feature is enabled, `wgpu-core` uses the | ||
//! [`ranked`] module's locks. We hope to make this the default for | ||
//! debug builds soon. | ||
//! | ||
//! Otherwise, `wgpu-core` uses the [`vanilla`] module's locks. | ||
//! | ||
//! [`Mutex`]: parking_lot::Mutex | ||
//! [`RwLock`]: parking_lot::RwLock | ||
//! [`SnatchLock`]: crate::snatch::SnatchLock | ||
|
||
pub mod rank; | ||
|
||
#[cfg_attr(feature = "validate-locks", allow(dead_code))] | ||
mod ranked; | ||
|
||
#[cfg_attr(not(feature = "validate-locks"), allow(dead_code))] | ||
mod vanilla; | ||
|
||
#[cfg(feature = "validate-locks")] | ||
pub use ranked::{Mutex, MutexGuard}; | ||
|
||
#[cfg(not(feature = "validate-locks"))] | ||
pub use vanilla::{Mutex, MutexGuard}; |
Oops, something went wrong.