mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-22 15:31:03 +01:00
[core] Implement downgrade for the lock module's RwLocks.
Implement `RwLockWriteGuard::downgrade` for `lock::vanilla` and `lock::ranked`, to downgrade a write lock to a read lock.
This commit is contained in:
1 parent
651214ef74
commit
7c842a3b48
2 files changed
+15
No files matched your search
@@ -281,6 +281,15 @@ impl<T> RwLock<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> RwLockWriteGuard<'a, T> {
|
||||
pub fn downgrade(this: Self) -> RwLockReadGuard<'a, T> {
|
||||
RwLockReadGuard {
|
||||
inner: parking_lot::RwLockWriteGuard::downgrade(this.inner),
|
||||
saved: this.saved,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: std::fmt::Debug> std::fmt::Debug for RwLock<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.inner.fmt(f)
|
||||
|
||||
@@ -86,6 +86,12 @@ impl<T> RwLock<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> RwLockWriteGuard<'a, T> {
|
||||
pub fn downgrade(this: Self) -> RwLockReadGuard<'a, T> {
|
||||
RwLockReadGuard(parking_lot::RwLockWriteGuard::downgrade(this.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: std::fmt::Debug> std::fmt::Debug for RwLock<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
|
||||
Reference in new issue
Block a user