id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/src/sync/rwlock.rs:3 | ///
/// This structure is created by the [`read`] method on
/// [`RwLock`].
///
/// [`read`]: method@RwLock::read
#[derive(Debug)]
pub struct RwLockReadGuard<'a, T> {
permit: ReleasingPermit<'a, T>,
lock: &'a RwLock<T>,
}
/// RAII structure used to release the exclusive write access of a lock when
/// dropped.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/sync/rwlock.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:4 | }
impl<'a, T> Drop for ReleasingPermit<'a, T> {
fn drop(&mut self) {
self.lock.s.release(self.num_permits as usize);
}
}
#[test]
#[cfg(not(loom))]
fn bounds() {
fn check_send<T: Send>() {}
fn check_sync<T: Sync>() {}
fn check_unpin<T: Unpin>() {}
// This has to take a value, since the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/sync/rwlock.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:6 | /// let r = c_lock.read().await;
/// assert_eq!(*r, 1);
/// }).await.expect("The spawned task has paniced");
///
/// // Drop the guard after the spawned task finishes.
/// drop(n);
///}
/// ```
pub async fn read(&self) -> RwLockReadGuard<'_, T> {
let p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/sync/rwlock.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:7 | let permit = ReleasingPermit::acquire(self, MAX_READS as u16)
.await
.unwrap_or_else(|_| {
// The semaphore was closed. but, we never explicitly close it, and we have a
// handle to it through the Arc, which means that this can never happen.
unreac... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/sync/rwlock.rs | 241 | 293 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:8 | fn from(s: T) -> Self {
Self::new(s)
}
}
impl<T> Default for RwLock<T>
where
T: Default,
{
fn default() -> Self {
Self::new(T::default())
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/sync/rwlock.rs | 281 | 293 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:3 | /// dropped.
///
/// This structure is created by the [`read`] method on
/// [`RwLock`].
///
/// [`read`]: method@RwLock::read
#[derive(Debug)]
pub struct RwLockReadGuard<'a, T> {
permit: ReleasingPermit<'a, T>,
lock: &'a RwLock<T>,
}
/// RAII structure used to release the exclusive write access of a lock when... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | f39c15334e74b07a44efaa0f7201262e17e4f062 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/sync/rwlock.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:4 | }
}
impl<'a, T> Drop for ReleasingPermit<'a, T> {
fn drop(&mut self) {
self.lock.s.release(self.num_permits as usize);
}
}
#[test]
#[cfg(not(loom))]
fn bounds() {
fn check_send<T: Send>() {}
fn check_sync<T: Sync>() {}
fn check_unpin<T: Unpin>() {}
// This has to take a value, since th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | f39c15334e74b07a44efaa0f7201262e17e4f062 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/sync/rwlock.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:6 | /// // While main has an active read lock, we acquire one too.
/// let r = c_lock.read().await;
/// assert_eq!(*r, 1);
/// }).await.expect("The spawned task has paniced");
///
/// // Drop the guard after the spawned task finishes.
/// drop(n);
///}
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | f39c15334e74b07a44efaa0f7201262e17e4f062 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/sync/rwlock.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:7 | pub async fn write(&self) -> RwLockWriteGuard<'_, T> {
let permit = ReleasingPermit::acquire(self, MAX_READS as u16)
.await
.unwrap_or_else(|_| {
// The semaphore was closed. but, we never explicitly close it, and we have a
// handle to it through the Arc,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | f39c15334e74b07a44efaa0f7201262e17e4f062 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/sync/rwlock.rs | 241 | 294 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:8 | impl<T> From<T> for RwLock<T> {
fn from(s: T) -> Self {
Self::new(s)
}
}
impl<T> Default for RwLock<T>
where
T: Default,
{
fn default() -> Self {
Self::new(T::default())
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | f39c15334e74b07a44efaa0f7201262e17e4f062 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/sync/rwlock.rs | 281 | 294 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:3 | /// dropped.
///
/// This structure is created by the [`read`] method on
/// [`RwLock`].
///
/// [`read`]: struct.RwLock.html#method.read
#[derive(Debug)]
pub struct RwLockReadGuard<'a, T> {
permit: ReleasingPermit<'a, T>,
lock: &'a RwLock<T>,
}
/// RAII structure used to release the exclusive write access of ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | 1121a8eb23f6f0edd9f41cdc08331d40e18105ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1121a8eb23f6f0edd9f41cdc08331d40e18105ee/tokio/src/sync/rwlock.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:3 | /// dropped.
///
/// This structure is created by the [`read`] method on
/// [`RwLock`].
///
/// [`read`]: struct.RwLock.html#method.read
#[derive(Debug)]
pub struct RwLockReadGuard<'a, T> {
permit: ReleasingPermit<'a, T>,
lock: &'a RwLock<T>,
}
/// RAII structure used to release the exclusive write access of ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | acf8a7da7a64bf08d578db9a9836a8e061765314 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/sync/rwlock.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:4 | }
}
impl<'a, T> Drop for ReleasingPermit<'a, T> {
fn drop(&mut self) {
self.lock.s.release(self.num_permits as usize);
}
}
#[test]
#[cfg(not(loom))]
fn bounds() {
fn check_send<T: Send>() {}
fn check_sync<T: Sync>() {}
fn check_unpin<T: Unpin>() {}
check_send::<RwLock<u32>>();
chec... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | acf8a7da7a64bf08d578db9a9836a8e061765314 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/sync/rwlock.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:6 | ///}
/// ```
pub async fn read(&self) -> RwLockReadGuard<'_, T> {
let permit = ReleasingPermit::acquire(self, 1).await.unwrap_or_else(|_| {
// The semaphore was closed. but, we never explicitly close it, and we have a
// handle to it through the Arc, which means that this can nev... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | acf8a7da7a64bf08d578db9a9836a8e061765314 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/sync/rwlock.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:7 | });
RwLockWriteGuard { lock: self, permit }
}
/// Consumes the lock, returning the underlying data.
pub fn into_inner(self) -> T {
self.c.into_inner()
}
}
impl<T> ops::Deref for RwLockReadGuard<'_, T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.lock.c.g... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | acf8a7da7a64bf08d578db9a9836a8e061765314 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/sync/rwlock.rs | 241 | 287 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:3 | /// RAII structure used to release the shared read access of a lock when
/// dropped.
///
/// This structure is created by the [`read`] method on
/// [`RwLock`].
///
/// [`read`]: struct.RwLock.html#method.read
#[derive(Debug)]
pub struct RwLockReadGuard<'a, T> {
permit: ReleasingPermit<'a, T>,
lock: &'a RwLock... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | c3b830110aa3f13346721dc148e074c122c7ddbe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3b830110aa3f13346721dc148e074c122c7ddbe/tokio/src/sync/rwlock.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:4 | ) -> Poll<Result<(), AcquireError>> {
// Keep track of task budget
ready!(crate::coop::poll_proceed(cx));
self.permit.poll_acquire(cx, self.num_permits, s)
}
}
impl<'a, T> Drop for ReleasingPermit<'a, T> {
fn drop(&mut self) {
self.permit.release(self.num_permits, &self.lock.s)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | c3b830110aa3f13346721dc148e074c122c7ddbe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3b830110aa3f13346721dc148e074c122c7ddbe/tokio/src/sync/rwlock.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:6 | // The semaphore was closed. but, we never explicitly close it, and we have a
// handle to it through the Arc, which means that this can never happen.
unreachable!()
});
RwLockReadGuard { lock: self, permit }
}
/// Locks this rwlock with exclusive write acces... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | c3b830110aa3f13346721dc148e074c122c7ddbe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3b830110aa3f13346721dc148e074c122c7ddbe/tokio/src/sync/rwlock.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:7 | // handle to it through the Arc, which means that this can never happen.
unreachable!()
});
RwLockWriteGuard { lock: self, permit }
}
/// Consumes the lock, returning the underlying data.
pub fn into_inner(self) -> T {
self.c.into_inner()
}
}
impl<T> ops::D... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | c3b830110aa3f13346721dc148e074c122c7ddbe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c3b830110aa3f13346721dc148e074c122c7ddbe/tokio/src/sync/rwlock.rs | 241 | 289 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:6 | // The semaphore was closed. but, we never explicitly close it, and we have a
// handle to it through the Arc, which means that this can never happen.
unreachable!()
});
RwLockReadGuard { lock: self, permit }
}
/// Locks this rwlock with exclusive write acces... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | 06a4d895ec8787386058a24b422dfa9a8514bc8e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06a4d895ec8787386058a24b422dfa9a8514bc8e/tokio/src/sync/rwlock.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:7 | // handle to it through the Arc, which means that this can never happen.
unreachable!()
});
RwLockWriteGuard { lock: self, permit }
}
}
impl<T> ops::Deref for RwLockReadGuard<'_, T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.lock.c.get() }
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | 06a4d895ec8787386058a24b422dfa9a8514bc8e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06a4d895ec8787386058a24b422dfa9a8514bc8e/tokio/src/sync/rwlock.rs | 241 | 284 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:3 | /// RAII structure used to release the shared read access of a lock when
/// dropped.
///
/// This structure is created by the [`read`] method on
/// [`RwLock`].
///
/// [`read`]: struct.RwLock.html#method.read
#[derive(Debug)]
pub struct RwLockReadGuard<'a, T> {
permit: ReleasingPermit<'a, T>,
lock: &'a RwLock... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | 0605abacfc3b1b20f1eb02a182ed411ac3f2bfe6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0605abacfc3b1b20f1eb02a182ed411ac3f2bfe6/tokio/src/sync/rwlock.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:4 | ) -> Poll<Result<(), AcquireError>> {
self.permit.poll_acquire(cx, self.num_permits, s)
}
}
impl<'a, T> Drop for ReleasingPermit<'a, T> {
fn drop(&mut self) {
self.permit.release(self.num_permits, &self.lock.s);
}
}
// As long as T: Send + Sync, it's fine to send and share RwLock<T> betwee... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | 0605abacfc3b1b20f1eb02a182ed411ac3f2bfe6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0605abacfc3b1b20f1eb02a182ed411ac3f2bfe6/tokio/src/sync/rwlock.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:6 | });
RwLockReadGuard { lock: self, permit }
}
/// Locks this rwlock with exclusive write access, causing the current task
/// to yield until the lock has been acquired.
///
/// This function will not return while other writers or other readers
/// currently have access to the lock.
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | 0605abacfc3b1b20f1eb02a182ed411ac3f2bfe6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0605abacfc3b1b20f1eb02a182ed411ac3f2bfe6/tokio/src/sync/rwlock.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:7 | RwLockWriteGuard { lock: self, permit }
}
}
impl<T> ops::Deref for RwLockReadGuard<'_, T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.lock.c.get() }
}
}
impl<T> ops::Deref for RwLockWriteGuard<'_, T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.lo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | 0605abacfc3b1b20f1eb02a182ed411ac3f2bfe6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0605abacfc3b1b20f1eb02a182ed411ac3f2bfe6/tokio/src/sync/rwlock.rs | 241 | 281 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:4 | ) -> Poll<Result<(), AcquireError>> {
self.permit.poll_acquire(cx, self.num_permits, s)
}
}
impl<'a, T> Drop for ReleasingPermit<'a, T> {
fn drop(&mut self) {
self.permit.release(self.num_permits, &self.lock.s);
}
}
// As long as T: Send + Sync, it's fine to send and share RwLock<T> betwee... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | b37e4a438037689956ade41ebe9e5ec64d53199f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37e4a438037689956ade41ebe9e5ec64d53199f/tokio/src/sync/rwlock.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:6 | /// Locks this rwlock with exclusive write access, causing the current task
/// to yield it can be acquired.
///
/// This function will not return while other writers or other readers
/// currently have access to the lock.
///
/// Returns an RAII guard which will drop the write access of this rw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | b37e4a438037689956ade41ebe9e5ec64d53199f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37e4a438037689956ade41ebe9e5ec64d53199f/tokio/src/sync/rwlock.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:7 | impl<T> ops::Deref for RwLockReadGuard<'_, T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.lock.c.get() }
}
}
impl<T> ops::Deref for RwLockWriteGuard<'_, T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.lock.c.get() }
}
}
impl<T> ops::DerefMut for R... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | b37e4a438037689956ade41ebe9e5ec64d53199f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37e4a438037689956ade41ebe9e5ec64d53199f/tokio/src/sync/rwlock.rs | 241 | 277 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:2 | /// async fn main() {
/// let lock = RwLock::new(5);
///
/// // many reader locks can be held at once
/// {
/// let r1 = lock.read().await;
/// let r2 = lock.read().await;
/// assert_eq!(*r1, 5);
/// assert_eq!(*r2, 5);
/// } // read locks are dropped at this point
///
/// //... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | a939dc48b0da9b62e361f4e82e79f48e70caa4be | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a939dc48b0da9b62e361f4e82e79f48e70caa4be/tokio/src/sync/rwlock.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:3 | /// [`read`]: struct.RwLock.html#method.read
#[derive(Debug)]
pub struct RwLockReadGuard<'a, T> {
permit: ReleasingPermit<'a, T>,
lock: &'a RwLock<T>,
}
/// RAII structure used to release the exclusive write access of a lock when
/// dropped.
///
/// This structure is created by the [`write`] and method
/// on... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | a939dc48b0da9b62e361f4e82e79f48e70caa4be | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a939dc48b0da9b62e361f4e82e79f48e70caa4be/tokio/src/sync/rwlock.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:4 | fn drop(&mut self) {
self.permit.release(self.num_permits, &self.lock.s);
}
}
// As long as T: Send + Sync, it's fine to send and share RwLock<T> between threads.
// If T were not Send, sending and sharing a RwLock<T> would be bad, since you can access T through
// RwLock<T>.
unsafe impl<T> Send for RwLock... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | a939dc48b0da9b62e361f4e82e79f48e70caa4be | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a939dc48b0da9b62e361f4e82e79f48e70caa4be/tokio/src/sync/rwlock.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:5 | /// use std::sync::Arc;
/// use tokio::sync::RwLock;
///
/// #[tokio::main]
/// async fn main() {
/// let lock = Arc::new(RwLock::new(1));
/// let c_lock = lock.clone();
///
/// let n = lock.read().await;
/// assert_eq!(*n, 1);
///
/// tokio::spawn(async m... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | a939dc48b0da9b62e361f4e82e79f48e70caa4be | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a939dc48b0da9b62e361f4e82e79f48e70caa4be/tokio/src/sync/rwlock.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:6 | /// Returns an RAII guard which will drop the write access of this rwlock
/// when dropped.
///
/// # Examples
///
/// ```
/// use tokio::sync::RwLock;
///
/// #[tokio::main]
/// async fn main() {
/// let lock = RwLock::new(1);
///
/// let mut n = lock.write().await;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | a939dc48b0da9b62e361f4e82e79f48e70caa4be | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a939dc48b0da9b62e361f4e82e79f48e70caa4be/tokio/src/sync/rwlock.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:7 | }
}
impl<T> ops::Deref for RwLockWriteGuard<'_, T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.lock.c.get() }
}
}
impl<T> ops::DerefMut for RwLockWriteGuard<'_, T> {
fn deref_mut(&mut self) -> &mut T {
unsafe { &mut *self.lock.c.get() }
}
}
impl<T> From<T> for RwLo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | a939dc48b0da9b62e361f4e82e79f48e70caa4be | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a939dc48b0da9b62e361f4e82e79f48e70caa4be/tokio/src/sync/rwlock.rs | 241 | 271 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:6 | /// Returns an RAII guard which will drop the write access of this rwlock
/// when dropped.
///
/// # Examples
///
/// ```
/// use tokio::sync::RwLock;
///
/// #[tokio::main]
/// async fn main() {
/// let lock = RwLock::new(1);
///
/// let mut n = lock.write().await;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | 32e15b3a24ac177c92a78eb04e233534583eae17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32e15b3a24ac177c92a78eb04e233534583eae17/tokio/src/sync/rwlock.rs | 201 | 256 |
tokio-rs/tokio:tokio/src/sync/rwlock.rs:7 | }
}
impl<T> ops::Deref for RwLockWriteGuard<'_, T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.lock.c.get() }
}
}
impl<T> ops::DerefMut for RwLockWriteGuard<'_, T> {
fn deref_mut(&mut self) -> &mut T {
unsafe { &mut *self.lock.c.get() }
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock.rs | MIT | 32e15b3a24ac177c92a78eb04e233534583eae17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32e15b3a24ac177c92a78eb04e233534583eae17/tokio/src/sync/rwlock.rs | 241 | 256 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:1 | use crate::sync::rwlock::RwLock;
use std::marker::PhantomData;
use std::sync::Arc;
use std::{fmt, mem, ops, ptr};
/// Owned RAII structure used to release the shared read access of a lock when
/// dropped.
///
/// This structure is created by the [`read_owned`] method on
/// [`RwLock`].
///
/// [`read_owned`]: method@... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_read_guard.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:2 | resource_span: ptr::read(&me.resource_span),
lock: ptr::read(&me.lock),
data: me.data,
}
}
}
/// Makes a new `OwnedRwLockReadGuard` for a component of the locked data.
/// This operation cannot fail as the `OwnedRwLockReadGuard` passed in
/// already ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_read_guard.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:3 | let this = this.skip_drop();
OwnedRwLockReadGuard {
lock: this.lock,
data,
_p: PhantomData,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: this.resource_span,
}
}
/// Attempts to make a new [`OwnedRwLockReadGuard`] fo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_read_guard.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:4 | /// ```
#[inline]
pub fn try_map<F, V: ?Sized>(this: Self, f: F) -> Result<OwnedRwLockReadGuard<T, V>, Self>
where
F: FnOnce(&U) -> Option<&V>,
{
let data = match f(&*this) {
Some(data) => data as *const V,
None => return Err(this),
};
let this = t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_read_guard.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:5 | /// assert!(Arc::ptr_eq(&lock, OwnedRwLockReadGuard::rwlock(&guard)));
/// # }
/// ```
pub fn rwlock(this: &Self) -> &Arc<RwLock<T>> {
&this.lock
}
}
impl<T: ?Sized, U: ?Sized> ops::Deref for OwnedRwLockReadGuard<T, U> {
type Target = U;
fn deref(&self) -> &U {
unsafe { &*self.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_read_guard.rs | 161 | 208 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:2 | resource_span: ptr::read(&me.resource_span),
lock: ptr::read(&me.lock),
data: me.data,
}
}
}
/// Makes a new `OwnedRwLockReadGuard` for a component of the locked data.
/// This operation cannot fail as the `OwnedRwLockReadGuard` passed in
/// already ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_read_guard.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:3 | let this = this.skip_drop();
OwnedRwLockReadGuard {
lock: this.lock,
data,
_p: PhantomData,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: this.resource_span,
}
}
/// Attempts to make a new [`OwnedRwLockReadGuard`] fo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_read_guard.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:4 | /// ```
#[inline]
pub fn try_map<F, V: ?Sized>(this: Self, f: F) -> Result<OwnedRwLockReadGuard<T, V>, Self>
where
F: FnOnce(&U) -> Option<&V>,
{
let data = match f(&*this) {
Some(data) => data as *const V,
None => return Err(this),
};
let this = t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_read_guard.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:4 | /// ```
#[inline]
pub fn try_map<F, V: ?Sized>(this: Self, f: F) -> Result<OwnedRwLockReadGuard<T, V>, Self>
where
F: FnOnce(&U) -> Option<&V>,
{
let data = match f(&*this) {
Some(data) => data as *const V,
None => return Err(this),
};
let this = t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 24aac0add3547803b571e9d5c6d6c3ecbd09bb5b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/24aac0add3547803b571e9d5c6d6c3ecbd09bb5b/tokio/src/sync/rwlock/owned_read_guard.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:5 | where
U: fmt::Display,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&**self, f)
}
}
impl<T: ?Sized, U: ?Sized> Drop for OwnedRwLockReadGuard<T, U> {
fn drop(&mut self) {
self.lock.s.release(1);
#[cfg(all(tokio_unstable, feature = "tracing"))]
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 24aac0add3547803b571e9d5c6d6c3ecbd09bb5b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/24aac0add3547803b571e9d5c6d6c3ecbd09bb5b/tokio/src/sync/rwlock/owned_read_guard.rs | 161 | 182 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:1 | use crate::sync::rwlock::RwLock;
use std::fmt;
use std::marker::PhantomData;
use std::mem;
use std::mem::ManuallyDrop;
use std::ops;
use std::sync::Arc;
/// Owned RAII structure used to release the shared read access of a lock when
/// dropped.
///
/// This structure is created by the [`read_owned`] method on
/// [`Rw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | d6dbefcdc043da552615bf2c8ad1f3a9580a1735 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/rwlock/owned_read_guard.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:2 | ///
/// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// struct Foo(u32);
///
/// # #[tokio::main]
/// # async fn main() {
/// let lock = Arc::new(RwLock::new(Foo(1)));
///
/// let guard = lock.read_owned().await;
/// let guard = OwnedRwLockReadGuard::map(guard, |f| &f.0);
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | d6dbefcdc043da552615bf2c8ad1f3a9580a1735 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/rwlock/owned_read_guard.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:3 | /// already locked the data.
///
/// This is an associated function that needs to be used as
/// `OwnedRwLockReadGuard::try_map(..)`. A method would interfere with
/// methods of the same name on the contents of the locked data.
///
/// # Examples
///
/// ```
/// use std::sync::Arc;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | d6dbefcdc043da552615bf2c8ad1f3a9580a1735 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/rwlock/owned_read_guard.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:4 | Ok(OwnedRwLockReadGuard {
lock: ManuallyDrop::new(lock),
data,
_p: PhantomData,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span,
})
}
}
impl<T: ?Sized, U: ?Sized> ops::Deref for OwnedRwLockReadGuard<T, U> {
type Target = U;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | d6dbefcdc043da552615bf2c8ad1f3a9580a1735 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/rwlock/owned_read_guard.rs | 121 | 171 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:5 | #[cfg(all(tokio_unstable, feature = "tracing"))]
self.resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resource::state_update",
current_readers = 1,
current_readers.op = "sub",
)
});
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | d6dbefcdc043da552615bf2c8ad1f3a9580a1735 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/rwlock/owned_read_guard.rs | 161 | 171 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:1 | use crate::sync::rwlock::RwLock;
use std::fmt;
use std::marker::PhantomData;
use std::mem;
use std::mem::ManuallyDrop;
use std::ops;
use std::sync::Arc;
/// Owned RAII structure used to release the shared read access of a lock when
/// dropped.
///
/// This structure is created by the [`read_owned`] method on
/// [`Rw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/sync/rwlock/owned_read_guard.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:2 | /// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// struct Foo(u32);
///
/// # #[tokio::main]
/// # async fn main() {
/// let lock = Arc::new(RwLock::new(Foo(1)));
///
/// let guard = lock.read_owned().await;
/// let guard = OwnedRwLockReadGuard::map(guard, |f| &f.0);
///
/// as... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/sync/rwlock/owned_read_guard.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:3 | ///
/// This is an associated function that needs to be used as
/// `OwnedRwLockReadGuard::try_map(..)`. A method would interfere with
/// methods of the same name on the contents of the locked data.
///
/// # Examples
///
/// ```
/// use std::sync::Arc;
/// use tokio::sync::{RwLock,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/sync/rwlock/owned_read_guard.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:4 | lock: ManuallyDrop::new(lock),
data,
_p: PhantomData,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span,
})
}
}
impl<T: ?Sized, U: ?Sized> ops::Deref for OwnedRwLockReadGuard<T, U> {
type Target = U;
fn deref(&self) -> &U {
unsaf... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/sync/rwlock/owned_read_guard.rs | 121 | 170 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:1 | use crate::sync::rwlock::RwLock;
use std::fmt;
use std::marker::PhantomData;
use std::mem;
use std::mem::ManuallyDrop;
use std::ops;
use std::sync::Arc;
/// Owned RAII structure used to release the shared read access of a lock when
/// dropped.
///
/// This structure is created by the [`read_owned`] method on
/// [`Rw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/rwlock/owned_read_guard.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:2 | ///
/// # #[tokio::main]
/// # async fn main() {
/// let lock = Arc::new(RwLock::new(Foo(1)));
///
/// let guard = lock.read_owned().await;
/// let guard = OwnedRwLockReadGuard::map(guard, |f| &f.0);
///
/// assert_eq!(1, *guard);
/// # }
/// ```
#[inline]
pub fn map<F, V... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/rwlock/owned_read_guard.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:3 | /// ```
/// use std::sync::Arc;
/// use tokio::sync::{RwLock, OwnedRwLockReadGuard};
///
/// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// struct Foo(u32);
///
/// # #[tokio::main]
/// # async fn main() {
/// let lock = Arc::new(RwLock::new(Foo(1)));
///
/// let guard = lo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/rwlock/owned_read_guard.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:4 | fn deref(&self) -> &U {
unsafe { &*self.data }
}
}
impl<T: ?Sized, U: ?Sized> fmt::Debug for OwnedRwLockReadGuard<T, U>
where
U: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&**self, f)
}
}
impl<T: ?Sized, U: ?Sized> fmt::Display for OwnedRwL... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/rwlock/owned_read_guard.rs | 121 | 149 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_read_guard.rs:1 | use crate::sync::rwlock::RwLock;
use std::fmt;
use std::marker::PhantomData;
use std::mem;
use std::mem::ManuallyDrop;
use std::ops;
use std::sync::Arc;
/// Owned RAII structure used to release the shared read access of a lock when
/// dropped.
///
/// This structure is created by the [`read_owned`] method on
/// [`Rw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_read_guard.rs | MIT | 0dc4769708279a076e01a66dc53ec226083c1bdb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0dc4769708279a076e01a66dc53ec226083c1bdb/tokio/src/sync/rwlock/owned_read_guard.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:1 | use crate::sync::rwlock::owned_read_guard::OwnedRwLockReadGuard;
use crate::sync::rwlock::owned_write_guard_mapped::OwnedRwLockMappedWriteGuard;
use crate::sync::rwlock::RwLock;
use std::marker::PhantomData;
use std::sync::Arc;
use std::{fmt, mem, ops, ptr};
/// Owned RAII structure used to release the exclusive write... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_write_guard.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:2 | // forgets the originals, so in the end no value is duplicated.
unsafe {
Inner {
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: ptr::read(&me.resource_span),
permits_acquired: me.permits_acquired,
lock: ptr::read(&me.lo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_write_guard.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:3 | ///
/// assert_eq!(Foo(2), *lock.read().await);
/// # }
/// ```
#[inline]
pub fn map<F, U: ?Sized>(mut this: Self, f: F) -> OwnedRwLockMappedWriteGuard<T, U>
where
F: FnOnce(&mut T) -> &mut U,
{
let data = f(&mut *this) as *mut U;
let this = this.skip_drop();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_write_guard.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:4 | /// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// struct Foo(u32);
///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let lock = Arc::new(RwLock::new(Foo(1)));
///
/// let guard = Arc::clone(&lock).write_owned().await;
/// let mapped = OwnedRwLockWriteGuar... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_write_guard.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:5 | #[cfg(all(tokio_unstable, feature = "tracing"))]
guard.resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resource::state_update",
current_readers = 1,
current_readers.op = "add",
)
});
guard
}
/// Attempts to make... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_write_guard.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:6 | /// let guard = Arc::clone(&lock).write_owned().await;
/// let mut guard = OwnedRwLockWriteGuard::try_map(guard, |f| Some(&mut f.0)).expect("should not fail");
/// *guard = 2;
/// }
///
/// assert_eq!(Foo(2), *lock.read().await);
/// # }
/// ```
#[inline]
pub fn try_map<F... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_write_guard.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:7 | /// used as `OwnedRwLockWriteGuard::try_downgrade_map(...)`. A method would interfere with
/// methods of the same name on the contents of the locked data.
///
/// Inside of `f`, you retain exclusive access to the data, despite only being given a `&T`. Handing out a
/// `&mut T` would result in unsoundn... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_write_guard.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:8 | let guard = OwnedRwLockReadGuard {
lock: this.lock,
data,
_p: PhantomData,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: this.resource_span,
};
// Release all but one of the permits held by the write guard
let to_rele... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_write_guard.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:9 | Self::map(this, |me| me)
}
/// Atomically downgrades a write lock into a read lock without allowing
/// any writers to take exclusive access of the lock in the meantime.
///
/// **Note:** This won't *necessarily* allow any additional readers to acquire
/// locks, since [`RwLock`] is fair and it... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_write_guard.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:10 | let guard = OwnedRwLockReadGuard {
lock: this.lock,
data: this.data,
_p: PhantomData,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: this.resource_span,
};
// Release all but one of the permits held by the write guard
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_write_guard.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:11 | ///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let lock = Arc::new(RwLock::new(1));
///
/// let guard = lock.clone().write_owned().await;
/// assert!(Arc::ptr_eq(&lock, OwnedRwLockWriteGuard::rwlock(&guard)));
/// # }
/// ```
pub fn rwlock(this: &Self... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_write_guard.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:12 | {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&**self, f)
}
}
impl<T: ?Sized> Drop for OwnedRwLockWriteGuard<T> {
fn drop(&mut self) {
self.lock.s.release(self.permits_acquired as usize);
#[cfg(all(tokio_unstable, feature = "tracing"))]
self... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock/owned_write_guard.rs | 441 | 460 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:2 | // forgets the originals, so in the end no value is duplicated.
unsafe {
Inner {
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: ptr::read(&me.resource_span),
permits_acquired: me.permits_acquired,
lock: ptr::read(&me.lo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_write_guard.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:3 | ///
/// assert_eq!(Foo(2), *lock.read().await);
/// # }
/// ```
#[inline]
pub fn map<F, U: ?Sized>(mut this: Self, f: F) -> OwnedRwLockMappedWriteGuard<T, U>
where
F: FnOnce(&mut T) -> &mut U,
{
let data = f(&mut *this) as *mut U;
let this = this.skip_drop();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_write_guard.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:4 | /// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// struct Foo(u32);
///
/// # #[tokio::main]
/// # async fn main() {
/// let lock = Arc::new(RwLock::new(Foo(1)));
///
/// let guard = Arc::clone(&lock).write_owned().await;
/// let mapped = OwnedRwLockWriteGuard::downgrade_map(guard, |f|... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_write_guard.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:5 | #[cfg(all(tokio_unstable, feature = "tracing"))]
guard.resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resource::state_update",
current_readers = 1,
current_readers.op = "add",
)
});
guard
}
/// Attempts to make... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_write_guard.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:6 | /// let guard = Arc::clone(&lock).write_owned().await;
/// let mut guard = OwnedRwLockWriteGuard::try_map(guard, |f| Some(&mut f.0)).expect("should not fail");
/// *guard = 2;
/// }
///
/// assert_eq!(Foo(2), *lock.read().await);
/// # }
/// ```
#[inline]
pub fn try_map<F... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_write_guard.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:7 | /// used as `OwnedRwLockWriteGuard::try_downgrade_map(...)`. A method would interfere with
/// methods of the same name on the contents of the locked data.
///
/// Inside of `f`, you retain exclusive access to the data, despite only being given a `&T`. Handing out a
/// `&mut T` would result in unsoundn... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_write_guard.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:8 | let guard = OwnedRwLockReadGuard {
lock: this.lock,
data,
_p: PhantomData,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: this.resource_span,
};
// Release all but one of the permits held by the write guard
let to_rele... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_write_guard.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:9 | Self::map(this, |me| me)
}
/// Atomically downgrades a write lock into a read lock without allowing
/// any writers to take exclusive access of the lock in the meantime.
///
/// **Note:** This won't *necessarily* allow any additional readers to acquire
/// locks, since [`RwLock`] is fair and it... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_write_guard.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:10 | let guard = OwnedRwLockReadGuard {
lock: this.lock,
data: this.data,
_p: PhantomData,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: this.resource_span,
};
// Release all but one of the permits held by the write guard
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_write_guard.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:11 | ///
/// # #[tokio::main]
/// # async fn main() {
/// let lock = Arc::new(RwLock::new(1));
///
/// let guard = lock.clone().write_owned().await;
/// assert!(Arc::ptr_eq(&lock, OwnedRwLockWriteGuard::rwlock(&guard)));
/// # }
/// ```
pub fn rwlock(this: &Self) -> &Arc<RwLock<T>> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4565b81097e8938761431592c0ad36df3bd20cd2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4565b81097e8938761431592c0ad36df3bd20cd2/tokio/src/sync/rwlock/owned_write_guard.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:10 | let guard = OwnedRwLockReadGuard {
lock: this.lock,
data: this.data,
_p: PhantomData,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: this.resource_span,
};
// Release all but one of the permits held by the write guard
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 002f4a28c882d127a665bb8d71f751d4eb5e1b22 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/002f4a28c882d127a665bb8d71f751d4eb5e1b22/tokio/src/sync/rwlock/owned_write_guard.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:11 | }
impl<T: ?Sized> ops::DerefMut for OwnedRwLockWriteGuard<T> {
fn deref_mut(&mut self) -> &mut T {
unsafe { &mut *self.data }
}
}
impl<T: ?Sized> fmt::Debug for OwnedRwLockWriteGuard<T>
where
T: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&*... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 002f4a28c882d127a665bb8d71f751d4eb5e1b22 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/002f4a28c882d127a665bb8d71f751d4eb5e1b22/tokio/src/sync/rwlock/owned_write_guard.rs | 401 | 440 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:3 | ///
/// assert_eq!(Foo(2), *lock.read().await);
/// # }
/// ```
#[inline]
pub fn map<F, U: ?Sized>(mut this: Self, f: F) -> OwnedRwLockMappedWriteGuard<T, U>
where
F: FnOnce(&mut T) -> &mut U,
{
let data = f(&mut *this) as *mut U;
let this = this.skip_drop();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 24aac0add3547803b571e9d5c6d6c3ecbd09bb5b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/24aac0add3547803b571e9d5c6d6c3ecbd09bb5b/tokio/src/sync/rwlock/owned_write_guard.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:4 | ///
/// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// struct Foo(u32);
///
/// # #[tokio::main]
/// # async fn main() {
/// let lock = Arc::new(RwLock::new(Foo(1)));
///
/// {
/// let guard = Arc::clone(&lock).write_owned().await;
/// let mut guard = OwnedRwLockWriteGu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 24aac0add3547803b571e9d5c6d6c3ecbd09bb5b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/24aac0add3547803b571e9d5c6d6c3ecbd09bb5b/tokio/src/sync/rwlock/owned_write_guard.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:5 | /// Converts this `OwnedRwLockWriteGuard` into an
/// `OwnedRwLockMappedWriteGuard`. This method can be used to store a
/// non-mapped guard in a struct field that expects a mapped guard.
///
/// This is equivalent to calling `OwnedRwLockWriteGuard::map(guard, |me| me)`.
#[inline]
pub fn into_ma... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 24aac0add3547803b571e9d5c6d6c3ecbd09bb5b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/24aac0add3547803b571e9d5c6d6c3ecbd09bb5b/tokio/src/sync/rwlock/owned_write_guard.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:6 | ///
/// drop(n);
/// handle.await.unwrap();
/// assert_eq!(*lock.read().await, 2, "second writer obtained write lock");
/// # }
/// ```
pub fn downgrade(self) -> OwnedRwLockReadGuard<T> {
let this = self.skip_drop();
let guard = OwnedRwLockReadGuard {
lock: this.lock,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 24aac0add3547803b571e9d5c6d6c3ecbd09bb5b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/24aac0add3547803b571e9d5c6d6c3ecbd09bb5b/tokio/src/sync/rwlock/owned_write_guard.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:7 | }
impl<T: ?Sized> ops::Deref for OwnedRwLockWriteGuard<T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.data }
}
}
impl<T: ?Sized> ops::DerefMut for OwnedRwLockWriteGuard<T> {
fn deref_mut(&mut self) -> &mut T {
unsafe { &mut *self.data }
}
}
impl<T: ?Sized> fmt::Deb... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 24aac0add3547803b571e9d5c6d6c3ecbd09bb5b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/24aac0add3547803b571e9d5c6d6c3ecbd09bb5b/tokio/src/sync/rwlock/owned_write_guard.rs | 241 | 288 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:1 | use crate::sync::rwlock::owned_read_guard::OwnedRwLockReadGuard;
use crate::sync::rwlock::owned_write_guard_mapped::OwnedRwLockMappedWriteGuard;
use crate::sync::rwlock::RwLock;
use std::fmt;
use std::marker::PhantomData;
use std::mem::{self, ManuallyDrop};
use std::ops;
use std::sync::Arc;
/// Owned RAII structure us... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | d6dbefcdc043da552615bf2c8ad1f3a9580a1735 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/rwlock/owned_write_guard.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:2 | ///
/// ```
/// use std::sync::Arc;
/// use tokio::sync::{RwLock, OwnedRwLockWriteGuard};
///
/// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// struct Foo(u32);
///
/// # #[tokio::main]
/// # async fn main() {
/// let lock = Arc::new(RwLock::new(Foo(1)));
///
/// {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | d6dbefcdc043da552615bf2c8ad1f3a9580a1735 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/rwlock/owned_write_guard.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:3 | resource_span,
}
}
/// Attempts to make a new [`OwnedRwLockMappedWriteGuard`] for a component
/// of the locked data. The original guard is returned if the closure
/// returns `None`.
///
/// This operation cannot fail as the `OwnedRwLockWriteGuard` passed in
/// already locked the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | d6dbefcdc043da552615bf2c8ad1f3a9580a1735 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/rwlock/owned_write_guard.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:4 | pub fn try_map<F, U: ?Sized>(
mut this: Self,
f: F,
) -> Result<OwnedRwLockMappedWriteGuard<T, U>, Self>
where
F: FnOnce(&mut T) -> Option<&mut U>,
{
let data = match f(&mut *this) {
Some(data) => data as *mut U,
None => return Err(this),
};
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | d6dbefcdc043da552615bf2c8ad1f3a9580a1735 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/rwlock/owned_write_guard.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:5 | /// any writers to take exclusive access of the lock in the meantime.
///
/// **Note:** This won't *necessarily* allow any additional readers to acquire
/// locks, since [`RwLock`] is fair and it is possible that a writer is next
/// in line.
///
/// Returns an RAII guard which will drop this re... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | d6dbefcdc043da552615bf2c8ad1f3a9580a1735 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/rwlock/owned_write_guard.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:6 | lock.s.release(to_release);
#[cfg(all(tokio_unstable, feature = "tracing"))]
self.resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resource::state_update",
write_locked = false,
write_locked.op = "override",
)
});
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | d6dbefcdc043da552615bf2c8ad1f3a9580a1735 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/rwlock/owned_write_guard.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:7 | }
impl<T: ?Sized> ops::DerefMut for OwnedRwLockWriteGuard<T> {
fn deref_mut(&mut self) -> &mut T {
unsafe { &mut *self.data }
}
}
impl<T: ?Sized> fmt::Debug for OwnedRwLockWriteGuard<T>
where
T: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&*... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | d6dbefcdc043da552615bf2c8ad1f3a9580a1735 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d6dbefcdc043da552615bf2c8ad1f3a9580a1735/tokio/src/sync/rwlock/owned_write_guard.rs | 241 | 280 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:1 | use crate::sync::rwlock::owned_read_guard::OwnedRwLockReadGuard;
use crate::sync::rwlock::owned_write_guard_mapped::OwnedRwLockMappedWriteGuard;
use crate::sync::rwlock::RwLock;
use std::fmt;
use std::marker::PhantomData;
use std::mem::{self, ManuallyDrop};
use std::ops;
use std::sync::Arc;
/// Owned RAII structure us... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/sync/rwlock/owned_write_guard.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:2 | /// ```
/// use std::sync::Arc;
/// use tokio::sync::{RwLock, OwnedRwLockWriteGuard};
///
/// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// struct Foo(u32);
///
/// # #[tokio::main]
/// # async fn main() {
/// let lock = Arc::new(RwLock::new(Foo(1)));
///
/// {
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/sync/rwlock/owned_write_guard.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:3 | }
}
/// Attempts to make a new [`OwnedRwLockMappedWriteGuard`] for a component
/// of the locked data. The original guard is returned if the closure
/// returns `None`.
///
/// This operation cannot fail as the `OwnedRwLockWriteGuard` passed in
/// already locked the data.
///
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/sync/rwlock/owned_write_guard.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/rwlock/owned_write_guard.rs:4 | mut this: Self,
f: F,
) -> Result<OwnedRwLockMappedWriteGuard<T, U>, Self>
where
F: FnOnce(&mut T) -> Option<&mut U>,
{
let data = match f(&mut *this) {
Some(data) => data as *mut U,
None => return Err(this),
};
let permits_acquired = this.perm... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/rwlock/owned_write_guard.rs | MIT | 4e3268d222423e874f5bbfa67e20f773da3c025f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4e3268d222423e874f5bbfa67e20f773da3c025f/tokio/src/sync/rwlock/owned_write_guard.rs | 121 | 180 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.