diff options
| author | Connor Tsui <connor.tsui20@gmail.com> | 2024-10-16 09:32:01 -0400 |
|---|---|---|
| committer | Connor Tsui <connor.tsui20@gmail.com> | 2024-11-16 12:31:13 -0500 |
| commit | 3336ae0838a1bc0f77854b7b40127d2e6bdca696 (patch) | |
| tree | 3f99c83698f097438001139ee7d7c5a7de3ee736 /library/std/src/sys/sync | |
| parent | f71ecc48cc130b8e056063062d69338e2bc4e1b2 (diff) | |
add simple `downgrade` implementations
Diffstat (limited to 'library/std/src/sys/sync')
| -rw-r--r-- | library/std/src/sys/sync/rwlock/no_threads.rs | 5 | ||||
| -rw-r--r-- | library/std/src/sys/sync/rwlock/solid.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sys/sync/rwlock/teeos.rs | 6 |
3 files changed, 17 insertions, 0 deletions
diff --git a/library/std/src/sys/sync/rwlock/no_threads.rs b/library/std/src/sys/sync/rwlock/no_threads.rs index 6965e2e2cab..c11e59f719e 100644 --- a/library/std/src/sys/sync/rwlock/no_threads.rs +++ b/library/std/src/sys/sync/rwlock/no_threads.rs @@ -62,4 +62,9 @@ impl RwLock { pub unsafe fn write_unlock(&self) { assert_eq!(self.mode.replace(0), -1); } + + #[inline] + pub unsafe fn downgrade(&self) { + assert_eq!(self.mode.replace(1), -1); + } } diff --git a/library/std/src/sys/sync/rwlock/solid.rs b/library/std/src/sys/sync/rwlock/solid.rs index 7703082f951..f664fef9074 100644 --- a/library/std/src/sys/sync/rwlock/solid.rs +++ b/library/std/src/sys/sync/rwlock/solid.rs @@ -79,6 +79,12 @@ impl RwLock { let rwl = self.raw(); expect_success_aborting(unsafe { abi::rwl_unl_rwl(rwl) }, &"rwl_unl_rwl"); } + + #[inline] + pub unsafe fn downgrade(&self) { + // The SOLID platform does not support the `downgrade` operation for reader writer locks, so + // this function is simply a no-op as only 1 reader can read: the original writer. + } } impl Drop for RwLock { diff --git a/library/std/src/sys/sync/rwlock/teeos.rs b/library/std/src/sys/sync/rwlock/teeos.rs index 76343022383..4a71a3abc27 100644 --- a/library/std/src/sys/sync/rwlock/teeos.rs +++ b/library/std/src/sys/sync/rwlock/teeos.rs @@ -41,4 +41,10 @@ impl RwLock { pub unsafe fn write_unlock(&self) { unsafe { self.inner.unlock() }; } + + #[inline] + pub unsafe fn downgrade(&self) { + // Since there is no difference between read-locked and write-locked on this platform, this + // function is simply a no-op as only 1 reader can read: the original writer. + } } |
