mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
[core] Implement downgrade
for the lock
module's RwLock
s.
Implement `RwLockWriteGuard::downgrade` for `lock::vanilla` and `lock::ranked`, to downgrade a write lock to a read lock.
This commit is contained in:
parent
651214ef74
commit
7c842a3b48
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user