• Home
  • Raw
  • Download

Lines Matching full:rwlock

29 /// Types implementing this trait can be used by `RwLock` to form a safe and
30 /// fully-functioning `RwLock` type.
34 /// Implementations of this trait must ensure that the `RwLock` is actually
39 /// Initial value for an unlocked `RwLock`.
75 /// Checks if this `RwLock` is currently locked in any way.
88 /// Check if this `RwLock` is currently exclusively locked.
191 /// to recursively lock a `RwLock`. However using this method can cause
330 pub struct RwLock<R, T: ?Sized> { struct
337 impl<R, T> Serialize for RwLock<R, T> argument
351 impl<'de, R, T> Deserialize<'de> for RwLock<R, T> implementation
360 Deserialize::deserialize(deserializer).map(RwLock::new) in deserialize()
364 unsafe impl<R: RawRwLock + Send, T: ?Sized + Send> Send for RwLock<R, T> {} implementation
365 unsafe impl<R: RawRwLock + Sync, T: ?Sized + Send + Sync> Sync for RwLock<R, T> {} implementation
367 impl<R: RawRwLock, T> RwLock<R, T> { impl
368 /// Creates a new instance of an `RwLock<T>` which is unlocked.
371 pub const fn new(val: T) -> RwLock<R, T> { in new()
372 RwLock { in new()
378 /// Creates a new instance of an `RwLock<T>` which is unlocked.
381 pub fn new(val: T) -> RwLock<R, T> { in new()
382 RwLock { in new()
388 /// Consumes this `RwLock`, returning the underlying data.
396 impl<R, T> RwLock<R, T> { implementation
397 /// Creates a new new instance of an `RwLock<T>` based on a pre-existing
400 /// This allows creating a `RwLock<T>` in a constant context on stable
403 pub const fn const_new(raw_rwlock: R, val: T) -> RwLock<R, T> { in const_new()
404 RwLock { in const_new()
411 impl<R: RawRwLock, T: ?Sized> RwLock<R, T> { impl
418 rwlock: self, in read_guard()
429 rwlock: self, in write_guard()
434 /// Locks this `RwLock` with shared read access, blocking the current thread
441 /// Note that attempts to recursively acquire a read lock on a `RwLock` when
453 /// Attempts to acquire this `RwLock` with shared read access.
470 /// Locks this `RwLock` with exclusive write access, blocking the current
476 /// Returns an RAII guard which will drop the write access of this `RwLock`
485 /// Attempts to lock this `RwLock` with exclusive write access.
504 /// Since this call borrows the `RwLock` mutably, no actual locking needs to
511 /// Checks whether this `RwLock` is currently locked in any way.
517 /// Check if this `RwLock` is currently exclusively locked.
533 /// Behavior is undefined if a rwlock is read-unlocked when not read-locked.
549 /// Behavior is undefined if a rwlock is write-unlocked when not write-locked.
593 rwlock: self.clone(), in read_guard_arc()
605 rwlock: self.clone(), in write_guard_arc()
610 /// Locks this `RwLock` with read access, through an `Arc`.
612 …/// This method is similar to the `read` method; however, it requires the `RwLock` to be inside of…
622 /// Attempts to lock this `RwLock` with read access, through an `Arc`.
624 …/// This method is similar to the `try_read` method; however, it requires the `RwLock` to be insid…
637 /// Locks this `RwLock` with write access, through an `Arc`.
639 …/// This method is similar to the `write` method; however, it requires the `RwLock` to be inside o…
649 /// Attempts to lock this `RwLock` with writ access, through an `Arc`.
651 …/// This method is similar to the `try_write` method; however, it requires the `RwLock` to be insi…
665 impl<R: RawRwLockFair, T: ?Sized> RwLock<R, T> { impl
676 /// Behavior is undefined if a rwlock is read-unlocked when not read-locked.
692 /// Behavior is undefined if a rwlock is write-unlocked when not write-locked.
699 impl<R: RawRwLockTimed, T: ?Sized> RwLock<R, T> { impl
700 /// Attempts to acquire this `RwLock` with shared read access until a timeout
716 /// Attempts to acquire this `RwLock` with shared read access until a timeout
732 /// Attempts to acquire this `RwLock` with exclusive write access until a
748 /// Attempts to acquire this `RwLock` with exclusive write access until a
764 …/// Attempts to acquire this `RwLock` with read access until a timeout is reached, through an `Arc…
766 …/// This method is similar to the `try_read_for` method; however, it requires the `RwLock` to be i…
782 …/// Attempts to acquire this `RwLock` with read access until a timeout is reached, through an `Arc…
784 …/// This method is similar to the `try_read_until` method; however, it requires the `RwLock` to be…
800 …/// Attempts to acquire this `RwLock` with write access until a timeout is reached, through an `Ar…
802 …/// This method is similar to the `try_write_for` method; however, it requires the `RwLock` to be …
818 …/// Attempts to acquire this `RwLock` with read access until a timeout is reached, through an `Arc…
820 …/// This method is similar to the `try_write_until` method; however, it requires the `RwLock` to b…
837 impl<R: RawRwLockRecursive, T: ?Sized> RwLock<R, T> { impl
838 /// Locks this `RwLock` with shared read access, blocking the current thread
847 /// to recursively lock a `RwLock`. However using this method can cause
860 /// Attempts to acquire this `RwLock` with shared read access.
880 /// Locks this `RwLock` with shared read access, through an `Arc`.
882 …/// This method is similar to the `read_recursive` method; however, it requires the `RwLock` to be…
892 /// Attempts to lock this `RwLock` with shared read access, through an `Arc`.
894 …/// This method is similar to the `try_read_recursive` method; however, it requires the `RwLock` t…
908 impl<R: RawRwLockRecursiveTimed, T: ?Sized> RwLock<R, T> { implementation
909 /// Attempts to acquire this `RwLock` with shared read access until a timeout
932 /// Attempts to acquire this `RwLock` with shared read access until a timeout
951 … /// Attempts to lock this `RwLock` with read access until a timeout is reached, through an `Arc`.
953 …s method is similar to the `try_read_recursive_for` method; however, it requires the `RwLock` to be
969 … /// Attempts to lock this `RwLock` with read access until a timeout is reached, through an `Arc`.
971 …method is similar to the `try_read_recursive_until` method; however, it requires the `RwLock` to be
988 impl<R: RawRwLockUpgrade, T: ?Sized> RwLock<R, T> { implementation
995 rwlock: self, in upgradable_guard()
1000 /// Locks this `RwLock` with upgradable read access, blocking the current thread
1016 /// Attempts to acquire this `RwLock` with upgradable read access.
1040 rwlock: self.clone(), in upgradable_guard_arc()
1045 /// Locks this `RwLock` with upgradable read access, through an `Arc`.
1047 …/// This method is similar to the `upgradable_read` method; however, it requires the `RwLock` to be
1057 /// Attempts to lock this `RwLock` with upgradable read access, through an `Arc`.
1059 …This method is similar to the `try_upgradable_read` method; however, it requires the `RwLock` to be
1073 impl<R: RawRwLockUpgradeTimed, T: ?Sized> RwLock<R, T> { implementation
1074 /// Attempts to acquire this `RwLock` with upgradable read access until a timeout
1093 /// Attempts to acquire this `RwLock` with upgradable read access until a timeout
1112 …/// Attempts to lock this `RwLock` with upgradable access until a timeout is reached, through an `…
1114 … method is similar to the `try_upgradable_read_for` method; however, it requires the `RwLock` to be
1130 …/// Attempts to lock this `RwLock` with upgradable access until a timeout is reached, through an `…
1132 …ethod is similar to the `try_upgradable_read_until` method; however, it requires the `RwLock` to be
1149 impl<R: RawRwLock, T: ?Sized + Default> Default for RwLock<R, T> { implementation
1151 fn default() -> RwLock<R, T> { in default()
1152 RwLock::new(Default::default()) in default()
1156 impl<R: RawRwLock, T> From<T> for RwLock<R, T> { implementation
1158 fn from(t: T) -> RwLock<R, T> { in from()
1159 RwLock::new(t) in from()
1163 impl<R: RawRwLock, T: ?Sized + fmt::Debug> fmt::Debug for RwLock<R, T> { implementation
1166 Some(guard) => f.debug_struct("RwLock").field("data", &&*guard).finish(), in fmt()
1175 f.debug_struct("RwLock") in fmt()
1185 #[must_use = "if unused the RwLock will immediately unlock"]
1187 rwlock: &'a RwLock<R, T>, field
1193 pub fn rwlock(s: &Self) -> &'a RwLock<R, T> { in rwlock() method
1194 s.rwlock in rwlock()
1210 let raw = &s.rwlock.raw; in map()
1211 let data = f(unsafe { &*s.rwlock.data.get() }); in map()
1234 let raw = &s.rwlock.raw; in try_map()
1235 let data = match f(unsafe { &*s.rwlock.data.get() }) { in try_map()
1247 /// Temporarily unlocks the `RwLock` to execute the given function.
1249 /// The `RwLock` is unlocked a fair unlock protocol.
1252 /// references to the data protected by the `RwLock`.
1260 s.rwlock.raw.unlock_shared(); in unlocked()
1262 defer!(s.rwlock.raw.lock_shared()); in unlocked()
1268 /// Unlocks the `RwLock` using a fair unlock protocol.
1270 /// By default, `RwLock` is unfair and allow the current thread to re-lock
1271 /// the `RwLock` before another has the chance to acquire the lock, even if
1272 /// that thread has been blocked on the `RwLock` for a long time. This is
1274 /// forcing a context switch on every `RwLock` unlock. This can result in one
1275 /// thread acquiring a `RwLock` many more times than other threads.
1284 s.rwlock.raw.unlock_shared_fair(); in unlock_fair()
1289 /// Temporarily unlocks the `RwLock` to execute the given function.
1291 /// The `RwLock` is unlocked a fair unlock protocol.
1294 /// references to the data protected by the `RwLock`.
1302 s.rwlock.raw.unlock_shared_fair(); in unlocked_fair()
1304 defer!(s.rwlock.raw.lock_shared()); in unlocked_fair()
1308 /// Temporarily yields the `RwLock` to a waiting thread if there is one.
1317 s.rwlock.raw.bump_shared(); in bump()
1326 unsafe { &*self.rwlock.data.get() } in deref()
1335 self.rwlock.raw.unlock_shared(); in drop()
1357 /// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`.
1359 …similar to the `RwLockReadGuard` struct, except instead of using a reference to unlock the `RwLock`
1360 /// it uses an `Arc<RwLock>`. This has several advantages, most notably that it has an `'static` li…
1362 #[must_use = "if unused the RwLock will immediately unlock"]
1364 rwlock: Arc<RwLock<R, T>>, field
1370 /// Returns a reference to the rwlock, contained in its `Arc`.
1371 pub fn rwlock(s: &Self) -> &Arc<RwLock<R, T>> { in rwlock() method
1372 &s.rwlock in rwlock()
1375 /// Temporarily unlocks the `RwLock` to execute the given function.
1385 s.rwlock.raw.unlock_shared(); in unlocked()
1387 defer!(s.rwlock.raw.lock_shared()); in unlocked()
1394 /// Unlocks the `RwLock` using a fair unlock protocol.
1401 s.rwlock.raw.unlock_shared_fair(); in unlock_fair()
1406 unsafe { ptr::drop_in_place(&mut s.rwlock) }; in unlock_fair()
1409 /// Temporarily unlocks the `RwLock` to execute the given function.
1419 s.rwlock.raw.unlock_shared_fair(); in unlocked_fair()
1421 defer!(s.rwlock.raw.lock_shared()); in unlocked_fair()
1425 /// Temporarily yields the `RwLock` to a waiting thread if there is one.
1432 s.rwlock.raw.bump_shared(); in bump()
1442 unsafe { &*self.rwlock.data.get() } in deref()
1452 self.rwlock.raw.unlock_shared(); in drop()
1473 #[must_use = "if unused the RwLock will immediately unlock"]
1475 rwlock: &'a RwLock<R, T>, field
1481 pub fn rwlock(s: &Self) -> &'a RwLock<R, T> { in rwlock() method
1482 s.rwlock in rwlock()
1498 let raw = &s.rwlock.raw; in map()
1499 let data = f(unsafe { &mut *s.rwlock.data.get() }); in map()
1522 let raw = &s.rwlock.raw; in try_map()
1523 let data = match f(unsafe { &mut *s.rwlock.data.get() }) { in try_map()
1535 /// Temporarily unlocks the `RwLock` to execute the given function.
1538 /// references to the data protected by the `RwLock`.
1546 s.rwlock.raw.unlock_exclusive(); in unlocked()
1548 defer!(s.rwlock.raw.lock_exclusive()); in unlocked()
1563 s.rwlock.raw.downgrade(); in downgrade()
1565 let rwlock = s.rwlock; in downgrade() localVariable
1568 rwlock, in downgrade()
1584 s.rwlock.raw.downgrade_to_upgradable(); in downgrade_to_upgradable()
1586 let rwlock = s.rwlock; in downgrade_to_upgradable() localVariable
1589 rwlock, in downgrade_to_upgradable()
1596 /// Unlocks the `RwLock` using a fair unlock protocol.
1598 /// By default, `RwLock` is unfair and allow the current thread to re-lock
1599 /// the `RwLock` before another has the chance to acquire the lock, even if
1600 /// that thread has been blocked on the `RwLock` for a long time. This is
1602 /// forcing a context switch on every `RwLock` unlock. This can result in one
1603 /// thread acquiring a `RwLock` many more times than other threads.
1612 s.rwlock.raw.unlock_exclusive_fair(); in unlock_fair()
1617 /// Temporarily unlocks the `RwLock` to execute the given function.
1619 /// The `RwLock` is unlocked a fair unlock protocol.
1622 /// references to the data protected by the `RwLock`.
1630 s.rwlock.raw.unlock_exclusive_fair(); in unlocked_fair()
1632 defer!(s.rwlock.raw.lock_exclusive()); in unlocked_fair()
1636 /// Temporarily yields the `RwLock` to a waiting thread if there is one.
1645 s.rwlock.raw.bump_exclusive(); in bump()
1654 unsafe { &*self.rwlock.data.get() } in deref()
1661 unsafe { &mut *self.rwlock.data.get() } in deref_mut()
1670 self.rwlock.raw.unlock_exclusive(); in drop()
1692 /// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`.
1693 …imilar to the `RwLockWriteGuard` struct, except instead of using a reference to unlock the `RwLock`
1694 /// it uses an `Arc<RwLock>`. This has several advantages, most notably that it has an `'static` li…
1696 #[must_use = "if unused the RwLock will immediately unlock"]
1698 rwlock: Arc<RwLock<R, T>>, field
1704 /// Returns a reference to the rwlock, contained in its `Arc`.
1705 pub fn rwlock(s: &Self) -> &Arc<RwLock<R, T>> { in rwlock() method
1706 &s.rwlock in rwlock()
1709 /// Temporarily unlocks the `RwLock` to execute the given function.
1719 s.rwlock.raw.unlock_exclusive(); in unlocked()
1721 defer!(s.rwlock.raw.lock_exclusive()); in unlocked()
1735 s.rwlock.raw.downgrade(); in downgrade()
1740 let rwlock = unsafe { ptr::read(&s.rwlock) }; in downgrade() localVariable
1743 rwlock, in downgrade()
1758 s.rwlock.raw.downgrade_to_upgradable(); in downgrade_to_upgradable()
1763 let rwlock = unsafe { ptr::read(&s.rwlock) }; in downgrade_to_upgradable() localVariable
1766 rwlock, in downgrade_to_upgradable()
1774 /// Unlocks the `RwLock` using a fair unlock protocol.
1781 s.rwlock.raw.unlock_exclusive_fair(); in unlock_fair()
1786 unsafe { ptr::drop_in_place(&mut s.rwlock) }; in unlock_fair()
1789 /// Temporarily unlocks the `RwLock` to execute the given function.
1799 s.rwlock.raw.unlock_exclusive_fair(); in unlocked_fair()
1801 defer!(s.rwlock.raw.lock_exclusive()); in unlocked_fair()
1805 /// Temporarily yields the `RwLock` to a waiting thread if there is one.
1812 s.rwlock.raw.bump_exclusive(); in bump()
1822 unsafe { &*self.rwlock.data.get() } in deref()
1830 unsafe { &mut *self.rwlock.data.get() } in deref_mut()
1840 self.rwlock.raw.unlock_exclusive(); in drop()
1861 #[must_use = "if unused the RwLock will immediately unlock"]
1863 rwlock: &'a RwLock<R, T>, field
1874 pub fn rwlock(s: &Self) -> &'a RwLock<R, T> { in rwlock() method
1875 s.rwlock in rwlock()
1878 /// Temporarily unlocks the `RwLock` to execute the given function.
1881 /// references to the data protected by the `RwLock`.
1889 s.rwlock.raw.unlock_upgradable(); in unlocked()
1891 defer!(s.rwlock.raw.lock_upgradable()); in unlocked()
1900 s.rwlock.raw.upgrade(); in upgrade()
1902 let rwlock = s.rwlock; in upgrade() localVariable
1905 rwlock, in upgrade()
1915 if unsafe { s.rwlock.raw.try_upgrade() } { in try_upgrade()
1916 let rwlock = s.rwlock; in try_upgrade() localVariable
1919 rwlock, in try_upgrade()
1929 /// Unlocks the `RwLock` using a fair unlock protocol.
1931 /// By default, `RwLock` is unfair and allow the current thread to re-lock
1932 /// the `RwLock` before another has the chance to acquire the lock, even if
1933 /// that thread has been blocked on the `RwLock` for a long time. This is
1935 /// forcing a context switch on every `RwLock` unlock. This can result in one
1936 /// thread acquiring a `RwLock` many more times than other threads.
1945 s.rwlock.raw.unlock_upgradable_fair(); in unlock_fair()
1950 /// Temporarily unlocks the `RwLock` to execute the given function.
1952 /// The `RwLock` is unlocked a fair unlock protocol.
1955 /// references to the data protected by the `RwLock`.
1963 s.rwlock.raw.unlock_upgradable_fair(); in unlocked_fair()
1965 defer!(s.rwlock.raw.lock_upgradable()); in unlocked_fair()
1969 /// Temporarily yields the `RwLock` to a waiting thread if there is one.
1978 s.rwlock.raw.bump_upgradable(); in bump()
1994 s.rwlock.raw.downgrade_upgradable(); in downgrade()
1996 let rwlock = s.rwlock; in downgrade() localVariable
1999 rwlock, in downgrade()
2016 if unsafe { s.rwlock.raw.try_upgrade_for(timeout) } { in try_upgrade_for()
2017 let rwlock = s.rwlock; in try_upgrade_for() localVariable
2020 rwlock, in try_upgrade_for()
2039 if unsafe { s.rwlock.raw.try_upgrade_until(timeout) } { in try_upgrade_until()
2040 let rwlock = s.rwlock; in try_upgrade_until() localVariable
2043 rwlock, in try_upgrade_until()
2056 unsafe { &*self.rwlock.data.get() } in deref()
2065 self.rwlock.raw.unlock_upgradable(); in drop()
2092 /// An RAII rwlock guard returned by the `Arc` locking operations on `RwLock`.
2094 /// `RwLock` it uses an `Arc<RwLock>`. This has several advantages, most notably that it has an `'s…
2097 #[must_use = "if unused the RwLock will immediately unlock"]
2099 rwlock: Arc<RwLock<R, T>>, field
2105 /// Returns a reference to the rwlock, contained in its original `Arc`.
2106 pub fn rwlock(s: &Self) -> &Arc<RwLock<R, T>> { in rwlock() method
2107 &s.rwlock in rwlock()
2110 /// Temporarily unlocks the `RwLock` to execute the given function.
2120 s.rwlock.raw.unlock_upgradable(); in unlocked()
2122 defer!(s.rwlock.raw.lock_upgradable()); in unlocked()
2131 s.rwlock.raw.upgrade(); in upgrade()
2137 let rwlock = unsafe { ptr::read(&s.rwlock) }; in upgrade() localVariable
2140 rwlock, in upgrade()
2150 if unsafe { s.rwlock.raw.try_upgrade() } { in try_upgrade()
2153 let rwlock = unsafe { ptr::read(&s.rwlock) }; in try_upgrade() localVariable
2156 rwlock, in try_upgrade()
2167 /// Unlocks the `RwLock` using a fair unlock protocol.
2174 s.rwlock.raw.unlock_upgradable_fair(); in unlock_fair()
2179 unsafe { ptr::drop_in_place(&mut s.rwlock) }; in unlock_fair()
2182 /// Temporarily unlocks the `RwLock` to execute the given function.
2192 s.rwlock.raw.unlock_upgradable_fair(); in unlocked_fair()
2194 defer!(s.rwlock.raw.lock_upgradable()); in unlocked_fair()
2198 /// Temporarily yields the `RwLock` to a waiting thread if there is one.
2205 s.rwlock.raw.bump_upgradable(); in bump()
2222 s.rwlock.raw.downgrade_upgradable(); in downgrade()
2227 let rwlock = unsafe { ptr::read(&s.rwlock) }; in downgrade() localVariable
2230 rwlock, in downgrade()
2248 if unsafe { s.rwlock.raw.try_upgrade_for(timeout) } { in try_upgrade_for()
2251 let rwlock = unsafe { ptr::read(&s.rwlock) }; in try_upgrade_for() localVariable
2254 rwlock, in try_upgrade_for()
2273 if unsafe { s.rwlock.raw.try_upgrade_until(timeout) } { in try_upgrade_until()
2276 let rwlock = unsafe { ptr::read(&s.rwlock) }; in try_upgrade_until() localVariable
2279 rwlock, in try_upgrade_until()
2293 unsafe { &*self.rwlock.data.get() } in deref()
2303 self.rwlock.raw.unlock_upgradable(); in drop()
2333 #[must_use = "if unused the RwLock will immediately unlock"]
2399 /// Unlocks the `RwLock` using a fair unlock protocol.
2401 /// By default, `RwLock` is unfair and allow the current thread to re-lock
2402 /// the `RwLock` before another has the chance to acquire the lock, even if
2403 /// that thread has been blocked on the `RwLock` for a long time. This is
2405 /// forcing a context switch on every `RwLock` unlock. This can result in one
2406 /// thread acquiring a `RwLock` many more times than other threads.
2468 #[must_use = "if unused the RwLock will immediately unlock"]
2537 /// Unlocks the `RwLock` using a fair unlock protocol.
2539 /// By default, `RwLock` is unfair and allow the current thread to re-lock
2540 /// the `RwLock` before another has the chance to acquire the lock, even if
2541 /// that thread has been blocked on the `RwLock` for a long time. This is
2543 /// forcing a context switch on every `RwLock` unlock. This can result in one
2544 /// thread acquiring a `RwLock` many more times than other threads.