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/oneshot.rs:1
#![cfg_attr(not(feature = "sync"), allow(dead_code, unreachable_pub))] //! A channel for sending a single message between asynchronous tasks. use crate::loom::cell::CausalCell; use crate::loom::sync::atomic::AtomicUsize; use crate::loom::sync::Arc; use std::fmt; use std::future::Future; use std::mem::MaybeUninit; us...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
af07f5bee72bc5c93ed1331cdba3a10f9ae7f569
github
async-runtime
https://github.com/tokio-rs/tokio/blob/af07f5bee72bc5c93ed1331cdba3a10f9ae7f569/tokio/src/sync/oneshot.rs
1
60
tokio-rs/tokio:tokio/src/sync/oneshot.rs:2
/// Error returned by the `try_recv` function on `Receiver`. #[derive(Debug)] pub enum TryRecvError { /// The send half of the channel has not yet sent a value. Empty, /// The send half of the channel was dropped without sending a value. Closed, } // ===== impl RecvErro...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
af07f5bee72bc5c93ed1331cdba3a10f9ae7f569
github
async-runtime
https://github.com/tokio-rs/tokio/blob/af07f5bee72bc5c93ed1331cdba3a10f9ae7f569/tokio/src/sync/oneshot.rs
41
100
tokio-rs/tokio:tokio/src/sync/oneshot.rs:1
#![cfg_attr(not(feature = "sync"), allow(dead_code, unreachable_pub))] //! A channel for sending a single message between asynchronous tasks. use crate::loom::cell::CausalCell; use crate::loom::sync::atomic::AtomicUsize; use crate::loom::sync::Arc; use std::fmt; use std::future::Future; use std::mem::MaybeUninit; us...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
1
60
tokio-rs/tokio:tokio/src/sync/oneshot.rs:2
/// Error returned by the `try_recv` function on `Receiver`. #[derive(Debug)] pub struct TryRecvError(pub(super) ()); // ===== impl RecvError ===== impl fmt::Display for RecvError { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "channel closed") }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
41
100
tokio-rs/tokio:tokio/src/sync/oneshot.rs:3
rx_task: CausalCell<MaybeUninit<Waker>>, } #[derive(Clone, Copy)] struct State(usize); /// Create a new one-shot channel for sending single values across asynchronous /// tasks. /// /// The function returns separate "send" and "receive" handles. The `Sender` /// handle is used by the producer to send the value. The `...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
81
140
tokio-rs/tokio:tokio/src/sync/oneshot.rs:4
value: CausalCell::new(None), tx_task: CausalCell::new(MaybeUninit::uninit()), rx_task: CausalCell::new(MaybeUninit::uninit()), }); let tx = Sender { inner: Some(inner.clone()), }; let rx = Receiver { inner: Some(inner) }; (tx, rx) } impl<T> Sender<T> { /// Completes t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
121
180
tokio-rs/tokio:tokio/src/sync/oneshot.rs:5
pub fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<()> { let inner = self.inner.as_ref().unwrap(); let mut state = State::load(&inner.state, Acquire); if state.is_closed() { return Poll::Ready(()); } if state.is_tx_task_set() { let will_notify ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
161
220
tokio-rs/tokio:tokio/src/sync/oneshot.rs:6
} /// Wait for the associated [`Receiver`] handle to drop. /// /// # Return /// /// Returns a `Future` which must be awaited on. /// /// [`Receiver`]: struct.Receiver.html /// /// # Examples /// /// ``` /// use tokio::sync::oneshot; /// /// #[tokio::main] ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
201
260
tokio-rs/tokio:tokio/src/sync/oneshot.rs:7
pub fn is_closed(&self) -> bool { let inner = self.inner.as_ref().unwrap(); let state = State::load(&inner.state, Acquire); state.is_closed() } } impl<T> Drop for Sender<T> { fn drop(&mut self) { if let Some(inner) = self.inner.as_ref() { inner.complete(); }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
241
300
tokio-rs/tokio:tokio/src/sync/oneshot.rs:8
pub fn try_recv(&mut self) -> Result<T, TryRecvError> { let result = if let Some(inner) = self.inner.as_ref() { let state = State::load(&inner.state, Acquire); if state.is_complete() { match unsafe { inner.consume_value() } { Some(value) => Ok(value),...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
281
340
tokio-rs/tokio:tokio/src/sync/oneshot.rs:9
panic!("called after complete"); }; self.inner = None; Ready(Ok(ret)) } } impl<T> Inner<T> { fn complete(&self) -> bool { let prev = State::set_complete(&self.state); if prev.is_closed() { return false; } if prev.is_rx_task_set() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
321
380
tokio-rs/tokio:tokio/src/sync/oneshot.rs:10
// Check if the task is still the same if !will_notify { // Unset the task state = State::unset_rx_task(&self.state); if state.is_complete() { // Set the flag again so that the waker is released in drop ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
361
420
tokio-rs/tokio:tokio/src/sync/oneshot.rs:11
} /// Called by `Receiver` to indicate that the value will never be received. fn close(&self) { let prev = State::set_closed(&self.state); if prev.is_tx_task_set() && !prev.is_complete() { unsafe { self.with_tx_task(Waker::wake_by_ref); } } }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
401
460
tokio-rs/tokio:tokio/src/sync/oneshot.rs:12
let ptr: *mut Waker = (&mut *ptr).as_mut_ptr(); ptr.drop_in_place(); }); } unsafe fn drop_tx_task(&self) { self.tx_task.with_mut(|ptr| { let ptr: *mut Waker = (&mut *ptr).as_mut_ptr(); ptr.drop_in_place(); }); } unsafe fn set_rx_task(&self, c...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
441
500
tokio-rs/tokio:tokio/src/sync/oneshot.rs:13
if state.is_tx_task_set() { unsafe { self.drop_tx_task(); } } } } impl<T: fmt::Debug> fmt::Debug for Inner<T> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { use std::sync::atomic::Ordering::Relaxed; fmt.debug_struct("Inner") ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/oneshot.rs
481
540
tokio-rs/tokio:tokio/src/sync/oneshot.rs:1
//! A channel for sending a single message between asynchronous tasks. use crate::loom::cell::CausalCell; use crate::loom::sync::atomic::AtomicUsize; use crate::loom::sync::Arc; use std::fmt; use std::future::Future; use std::mem::MaybeUninit; use std::pin::Pin; use std::sync::atomic::Ordering::{self, AcqRel, Acquire...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
1
60
tokio-rs/tokio:tokio/src/sync/oneshot.rs:2
#[derive(Debug)] pub struct TryRecvError(pub(super) ()); // ===== impl RecvError ===== impl fmt::Display for RecvError { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "channel closed") } } impl ::std::error::Error for RecvError {} // ===...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
41
100
tokio-rs/tokio:tokio/src/sync/oneshot.rs:3
#[derive(Clone, Copy)] struct State(usize); /// Create a new one-shot channel for sending single values across asynchronous /// tasks. /// /// The function returns separate "send" and "receive" handles. The `Sender` /// handle is used by the producer to send the value. The `Receiver` handle is /// used by the consumer...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
81
140
tokio-rs/tokio:tokio/src/sync/oneshot.rs:4
rx_task: CausalCell::new(MaybeUninit::uninit()), }); let tx = Sender { inner: Some(inner.clone()), }; let rx = Receiver { inner: Some(inner) }; (tx, rx) } impl<T> Sender<T> { /// Completes this oneshot with a successful result. /// /// The function consumes `self` and notifies...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
121
180
tokio-rs/tokio:tokio/src/sync/oneshot.rs:5
let mut state = State::load(&inner.state, Acquire); if state.is_closed() { return Poll::Ready(()); } if state.is_tx_task_set() { let will_notify = unsafe { inner.with_tx_task(|w| w.will_wake(cx.waker())) }; if !will_notify { state = State::u...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
161
220
tokio-rs/tokio:tokio/src/sync/oneshot.rs:6
/// Wait for the associated [`Receiver`] handle to drop. /// /// # Return /// /// Returns a `Future` which must be awaited on. /// /// [`Receiver`]: struct.Receiver.html /// /// # Examples /// /// ``` /// use tokio::sync::oneshot; /// /// #[tokio::main] /// async ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
201
260
tokio-rs/tokio:tokio/src/sync/oneshot.rs:7
let state = State::load(&inner.state, Acquire); state.is_closed() } } impl<T> Drop for Sender<T> { fn drop(&mut self) { if let Some(inner) = self.inner.as_ref() { inner.complete(); } } } impl<T> Receiver<T> { /// Prevent the associated [`Sender`] handle from sending...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
241
300
tokio-rs/tokio:tokio/src/sync/oneshot.rs:8
let state = State::load(&inner.state, Acquire); if state.is_complete() { match unsafe { inner.consume_value() } { Some(value) => Ok(value), None => Err(TryRecvError(())), } } else if state.is_closed() { Err(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
281
340
tokio-rs/tokio:tokio/src/sync/oneshot.rs:9
self.inner = None; Ready(Ok(ret)) } } impl<T> Inner<T> { fn complete(&self) -> bool { let prev = State::set_complete(&self.state); if prev.is_closed() { return false; } if prev.is_rx_task_set() { // TODO: Consume waker? unsafe { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
321
380
tokio-rs/tokio:tokio/src/sync/oneshot.rs:10
if !will_notify { // Unset the task state = State::unset_rx_task(&self.state); if state.is_complete() { // Set the flag again so that the waker is released in drop State::set_rx_task(&self.state); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
361
420
tokio-rs/tokio:tokio/src/sync/oneshot.rs:11
/// Called by `Receiver` to indicate that the value will never be received. fn close(&self) { let prev = State::set_closed(&self.state); if prev.is_tx_task_set() && !prev.is_complete() { unsafe { self.with_tx_task(Waker::wake_by_ref); } } } /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
401
460
tokio-rs/tokio:tokio/src/sync/oneshot.rs:12
}); } unsafe fn drop_tx_task(&self) { self.tx_task.with_mut(|ptr| { let ptr: *mut Waker = (&mut *ptr).as_mut_ptr(); ptr.drop_in_place(); }); } unsafe fn set_rx_task(&self, cx: &mut Context<'_>) { self.rx_task.with_mut(|ptr| { let ptr: *mut Wa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
441
500
tokio-rs/tokio:tokio/src/sync/oneshot.rs:13
self.drop_tx_task(); } } } } impl<T: fmt::Debug> fmt::Debug for Inner<T> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { use std::sync::atomic::Ordering::Relaxed; fmt.debug_struct("Inner") .field("state", &State::load(&self.state, Relaxed)) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
481
540
tokio-rs/tokio:tokio/src/sync/oneshot.rs:14
} fn set_rx_task(cell: &AtomicUsize) -> State { let val = cell.fetch_or(RX_TASK_SET, AcqRel); State(val | RX_TASK_SET) } fn unset_rx_task(cell: &AtomicUsize) -> State { let val = cell.fetch_and(!RX_TASK_SET, AcqRel); State(val & !RX_TASK_SET) } fn is_closed(self) -...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/oneshot.rs
521
577
tokio-rs/tokio:tokio/src/sync/oneshot.rs:1
//! A channel for sending a single message between asynchronous tasks. use crate::loom::cell::CausalCell; use crate::loom::sync::atomic::AtomicUsize; use crate::loom::sync::Arc; use futures_core::ready; use std::fmt; use std::future::Future; use std::mem::MaybeUninit; use std::pin::Pin; use std::sync::atomic::Orderin...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
a6253ed05a1e0d14bc64915f5937c29092df9497
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/oneshot.rs
1
60
tokio-rs/tokio:tokio/src/sync/oneshot.rs:2
/// Error returned by the `try_recv` function on `Receiver`. #[derive(Debug)] pub struct TryRecvError(pub(super) ()); // ===== impl RecvError ===== impl fmt::Display for RecvError { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "channel closed") }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
a6253ed05a1e0d14bc64915f5937c29092df9497
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/oneshot.rs
41
100
tokio-rs/tokio:tokio/src/sync/oneshot.rs:3
} #[derive(Clone, Copy)] struct State(usize); /// Create a new one-shot channel for sending single values across asynchronous /// tasks. /// /// The function returns separate "send" and "receive" handles. The `Sender` /// handle is used by the producer to send the value. The `Receiver` handle is /// used by the consu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
a6253ed05a1e0d14bc64915f5937c29092df9497
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/oneshot.rs
81
140
tokio-rs/tokio:tokio/src/sync/oneshot.rs:4
tx_task: CausalCell::new(MaybeUninit::uninit()), rx_task: CausalCell::new(MaybeUninit::uninit()), }); let tx = Sender { inner: Some(inner.clone()), }; let rx = Receiver { inner: Some(inner) }; (tx, rx) } impl<T> Sender<T> { /// Completes this oneshot with a successful result. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
a6253ed05a1e0d14bc64915f5937c29092df9497
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/oneshot.rs
121
180
tokio-rs/tokio:tokio/src/sync/oneshot.rs:5
let inner = self.inner.as_ref().unwrap(); let mut state = State::load(&inner.state, Acquire); if state.is_closed() { return Poll::Ready(()); } if state.is_tx_task_set() { let will_notify = unsafe { inner.with_tx_task(|w| w.will_wake(cx.waker())) }; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
a6253ed05a1e0d14bc64915f5937c29092df9497
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/oneshot.rs
161
220
tokio-rs/tokio:tokio/src/sync/oneshot.rs:6
/// Wait for the associated [`Receiver`] handle to drop. /// /// # Return /// /// Returns a `Future` which must be awaited on. /// /// [`Receiver`]: struct.Receiver.html /// /// # Examples /// /// ``` /// use tokio::sync::oneshot; /// /// #[tokio::main] /// async ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
a6253ed05a1e0d14bc64915f5937c29092df9497
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/oneshot.rs
201
260
tokio-rs/tokio:tokio/src/sync/oneshot.rs:7
let inner = self.inner.as_ref().unwrap(); let state = State::load(&inner.state, Acquire); state.is_closed() } } impl<T> Drop for Sender<T> { fn drop(&mut self) { if let Some(inner) = self.inner.as_ref() { inner.complete(); } } } impl<T> Receiver<T> { /// Pr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
a6253ed05a1e0d14bc64915f5937c29092df9497
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/oneshot.rs
241
300
tokio-rs/tokio:tokio/src/sync/oneshot.rs:8
let result = if let Some(inner) = self.inner.as_ref() { let state = State::load(&inner.state, Acquire); if state.is_complete() { match unsafe { inner.consume_value() } { Some(value) => Ok(value), None => Err(TryRecvError(())), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/oneshot.rs
MIT
a6253ed05a1e0d14bc64915f5937c29092df9497
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/oneshot.rs
281
340
tokio-rs/tokio:tokio/src/sync/rwlock.rs:1
use crate::sync::batch_semaphore::{Semaphore, TryAcquireError}; use crate::sync::mutex::TryLockError; #[cfg(all(tokio_unstable, feature = "tracing"))] use crate::util::trace; use std::cell::UnsafeCell; use std::marker; use std::marker::PhantomData; use std::sync::Arc; pub(crate) mod owned_read_guard; pub(crate) mod ow...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
1
60
tokio-rs/tokio:tokio/src/sync/rwlock.rs:3
/// [`Mutex`]: struct@super::Mutex /// [`RwLock`]: struct@RwLock /// [`RwLockReadGuard`]: struct@RwLockReadGuard /// [`RwLockWriteGuard`]: struct@RwLockWriteGuard /// [`Send`]: trait@std::marker::Send /// [_write-preferring_]: https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock#Priority_policies pub struct RwLock...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
81
140
tokio-rs/tokio:tokio/src/sync/rwlock.rs:4
check_send::<RwLockWriteGuard<'_, u32>>(); check_sync::<RwLockWriteGuard<'_, u32>>(); check_unpin::<RwLockWriteGuard<'_, u32>>(); check_send::<RwLockMappedWriteGuard<'_, u32>>(); check_sync::<RwLockMappedWriteGuard<'_, u32>>(); check_unpin::<RwLockMappedWriteGuard<'_, u32>>(); check_send::<Own...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
121
180
tokio-rs/tokio:tokio/src/sync/rwlock.rs:5
{ } unsafe impl<T, U> Sync for OwnedRwLockReadGuard<T, U> where T: ?Sized + Send + Sync, U: ?Sized + Send + Sync, { } unsafe impl<T> Sync for RwLockWriteGuard<'_, T> where T: ?Sized + Send + Sync {} unsafe impl<T> Sync for OwnedRwLockWriteGuard<T> where T: ?Sized + Send + Sync {} unsafe impl<T> Sync for RwLockM...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
161
220
tokio-rs/tokio:tokio/src/sync/rwlock.rs:6
/// ``` #[track_caller] pub fn new(value: T) -> RwLock<T> where T: Sized, { #[cfg(all(tokio_unstable, feature = "tracing"))] let resource_span = { let location = std::panic::Location::caller(); let resource_span = tracing::trace_span!( pare...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
201
260
tokio-rs/tokio:tokio/src/sync/rwlock.rs:7
let s = resource_span.in_scope(|| Semaphore::new(MAX_READS as usize)); #[cfg(any(not(tokio_unstable), not(feature = "tracing")))] let s = Semaphore::new(MAX_READS as usize); RwLock { mr: MAX_READS, c: UnsafeCell::new(value), s, #[cfg(all(tokio_un...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
241
300
tokio-rs/tokio:tokio/src/sync/rwlock.rs:8
let resource_span = { let location = std::panic::Location::caller(); let resource_span = tracing::trace_span!( parent: None, "runtime.resource", concrete_type = "RwLock", kind = "Sync", loc.file = location.file(), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
281
340
tokio-rs/tokio:tokio/src/sync/rwlock.rs:9
mr: max_reads, c: UnsafeCell::new(value), s, #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span, } } /// Creates a new instance of an `RwLock<T>` which is unlocked. /// /// When using the `tracing` [unstable feature], a `RwLock` create...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
321
380
tokio-rs/tokio:tokio/src/sync/rwlock.rs:10
/// and allows a maximum of `max_reads` concurrent readers. /// /// # Examples /// /// ``` /// use tokio::sync::RwLock; /// /// static LOCK: RwLock<i32> = RwLock::const_with_max_readers(5, 1024); /// ``` /// /// # Panics /// /// Panics if `max_reads` is `0` or is bigger t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
361
420
tokio-rs/tokio:tokio/src/sync/rwlock.rs:11
/// by the current task. /// /// Returns an RAII guard which will drop this read access of the `RwLock` /// when dropped. /// /// # Cancel safety /// /// This method uses a queue to fairly distribute locks in the order they /// were requested. Cancelling a call to `read` makes you lose y...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
401
460
tokio-rs/tokio:tokio/src/sync/rwlock.rs:12
unreachable!() }); RwLockReadGuard { s: &self.s, data: self.c.get(), marker: PhantomData, #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: self.resource_span.clone(), } }; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
441
500
tokio-rs/tokio:tokio/src/sync/rwlock.rs:15
/// /// ``` /// use std::sync::Arc; /// use tokio::sync::RwLock; /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { /// let lock = Arc::new(RwLock::new(1)); /// let c_lock = lock.clone(); /// /// let n = lock.read_owned().await; /// assert_eq!(*n, 1);...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
561
620
tokio-rs/tokio:tokio/src/sync/rwlock.rs:16
} }; #[cfg(all(tokio_unstable, feature = "tracing"))] let acquire_fut = trace::async_op( move || acquire_fut, resource_span, "RwLock::read_owned", "poll", false, ); #[allow(clippy::let_and_return)] // this lint trigger...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
601
660
tokio-rs/tokio:tokio/src/sync/rwlock.rs:17
/// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { /// let lock = Arc::new(RwLock::new(1)); /// let c_lock = lock.clone(); /// /// let v = lock.try_read().unwrap(); /// assert_eq!(*v, 1); /// /// tokio::spawn(async move { /// // While main has an acti...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
641
700
tokio-rs/tokio:tokio/src/sync/rwlock.rs:18
) }); Ok(guard) } /// Attempts to acquire this `RwLock` with shared read access. /// /// If the access couldn't be acquired immediately, returns [`TryLockError`]. /// Otherwise, an RAII guard is returned which will release read access /// when dropped. /// /// This meth...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
681
740
tokio-rs/tokio:tokio/src/sync/rwlock.rs:19
/// // Drop the guard when spawned task finishes. /// drop(v); /// # } /// ``` pub fn try_read_owned(self: Arc<Self>) -> Result<OwnedRwLockReadGuard<T>, TryLockError> { match self.s.try_acquire(1) { Ok(permit) => permit, Err(TryAcquireError::NoPermits) => return Err(TryLo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
721
780
tokio-rs/tokio:tokio/src/sync/rwlock.rs:20
/// # Cancel safety /// /// This method uses a queue to fairly distribute locks in the order they /// were requested. Cancelling a call to `write` makes you lose your place /// in the queue. /// /// # Examples /// /// ``` /// use tokio::sync::RwLock; /// /// # #[tokio::main(f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
761
820
tokio-rs/tokio:tokio/src/sync/rwlock.rs:21
move || acquire_fut, self.resource_span.clone(), "RwLock::write", "poll", false, ); #[allow(clippy::let_and_return)] // this lint triggers when disabling tracing let guard = acquire_fut.await; #[cfg(all(tokio_unstable, feature = "tracing"...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
801
860
tokio-rs/tokio:tokio/src/sync/rwlock.rs:23
/// Locks this `RwLock` with exclusive write access, causing the current /// task to yield until the lock has been acquired. /// /// The calling task will yield while other writers or readers currently /// have access to the lock. /// /// This method is identical to [`RwLock::write`], except tha...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
881
940
tokio-rs/tokio:tokio/src/sync/rwlock.rs:24
debug_assert_ne!(self.mr, 0); self.s.acquire(self.mr as usize).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. unreachable!() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
921
980
tokio-rs/tokio:tokio/src/sync/rwlock.rs:25
/// Attempts to acquire this `RwLock` with exclusive write access. /// /// If the access couldn't be acquired immediately, returns [`TryLockError`]. /// Otherwise, an RAII guard is returned which will release write access /// when dropped. /// /// [`TryLockError`]: TryLockError /// /// #...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
961
1,020
tokio-rs/tokio:tokio/src/sync/rwlock.rs:26
#[cfg(all(tokio_unstable, feature = "tracing"))] self.resource_span.in_scope(|| { tracing::trace!( target: "runtime::resource::state_update", write_locked = true, write_locked.op = "override", ) }); Ok(guard) } /// Attempts to...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
1,001
1,060
tokio-rs/tokio:tokio/src/sync/rwlock.rs:27
/// assert!(rw.try_write_owned().is_err()); /// # } /// ``` pub fn try_write_owned(self: Arc<Self>) -> Result<OwnedRwLockWriteGuard<T>, TryLockError> { debug_assert_ne!(self.mr, 0); match self.s.try_acquire(self.mr as usize) { Ok(permit) => permit, Err(TryAcquireError...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
1,041
1,100
tokio-rs/tokio:tokio/src/sync/rwlock.rs:28
/// use tokio::sync::RwLock; /// /// fn main() { /// let mut lock = RwLock::new(1); /// /// let n = lock.get_mut(); /// *n = 2; /// } /// ``` pub fn get_mut(&mut self) -> &mut T { self.c.get_mut() } /// Consumes the lock, returning the underlying data. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
1,081
1,130
tokio-rs/tokio:tokio/src/sync/rwlock.rs:29
{ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut d = f.debug_struct("RwLock"); match self.try_read() { Ok(inner) => d.field("data", &&*inner), Err(_) => d.field("data", &format_args!("<locked>")), }; d.finish() } }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/rwlock.rs
1,121
1,130
tokio-rs/tokio:tokio/src/sync/rwlock.rs:1
use crate::sync::batch_semaphore::{Semaphore, TryAcquireError}; use crate::sync::mutex::TryLockError; #[cfg(all(tokio_unstable, feature = "tracing"))] use crate::util::trace; use std::cell::UnsafeCell; use std::marker; use std::marker::PhantomData; use std::sync::Arc; pub(crate) mod owned_read_guard; pub(crate) mod ow...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
1
60
tokio-rs/tokio:tokio/src/sync/rwlock.rs:3
/// /// [`Mutex`]: struct@super::Mutex /// [`RwLock`]: struct@RwLock /// [`RwLockReadGuard`]: struct@RwLockReadGuard /// [`RwLockWriteGuard`]: struct@RwLockWriteGuard /// [`Send`]: trait@std::marker::Send /// [_write-preferring_]: https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock#Priority_policies pub struct Rw...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
81
140
tokio-rs/tokio:tokio/src/sync/rwlock.rs:4
check_unpin::<OwnedRwLockReadGuard<u32, i32>>(); check_send::<RwLockWriteGuard<'_, u32>>(); check_sync::<RwLockWriteGuard<'_, u32>>(); check_unpin::<RwLockWriteGuard<'_, u32>>(); check_send::<RwLockMappedWriteGuard<'_, u32>>(); check_sync::<RwLockMappedWriteGuard<'_, u32>>(); check_unpin::<RwL...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
121
180
tokio-rs/tokio:tokio/src/sync/rwlock.rs:5
U: ?Sized + Sync, { } unsafe impl<T, U> Sync for OwnedRwLockReadGuard<T, U> where T: ?Sized + Send + Sync, U: ?Sized + Send + Sync, { } unsafe impl<T> Sync for RwLockWriteGuard<'_, T> where T: ?Sized + Send + Sync {} unsafe impl<T> Sync for OwnedRwLockWriteGuard<T> where T: ?Sized + Send + Sync {} unsafe impl<T...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
161
220
tokio-rs/tokio:tokio/src/sync/rwlock.rs:6
/// let lock = RwLock::new(5); /// ``` #[track_caller] pub fn new(value: T) -> RwLock<T> where T: Sized, { #[cfg(all(tokio_unstable, feature = "tracing"))] let resource_span = { let location = std::panic::Location::caller(); let resource_span = tracing...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
201
260
tokio-rs/tokio:tokio/src/sync/rwlock.rs:7
#[cfg(all(tokio_unstable, feature = "tracing"))] let s = resource_span.in_scope(|| Semaphore::new(MAX_READS as usize)); #[cfg(any(not(tokio_unstable), not(feature = "tracing")))] let s = Semaphore::new(MAX_READS as usize); RwLock { mr: MAX_READS, c: UnsafeCell::...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
241
300
tokio-rs/tokio:tokio/src/sync/rwlock.rs:8
#[cfg(all(tokio_unstable, feature = "tracing"))] let resource_span = { let location = std::panic::Location::caller(); let resource_span = tracing::trace_span!( parent: None, "runtime.resource", concrete_type = "RwLock", kin...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
281
340
tokio-rs/tokio:tokio/src/sync/rwlock.rs:9
RwLock { mr: max_reads, c: UnsafeCell::new(value), s, #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span, } } /// Creates a new instance of an `RwLock<T>` which is unlocked. /// /// When using the `tracing` [unstable featur...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
321
380
tokio-rs/tokio:tokio/src/sync/rwlock.rs:10
/// Creates a new instance of an `RwLock<T>` which is unlocked /// and allows a maximum of `max_reads` concurrent readers. /// /// # Examples /// /// ``` /// use tokio::sync::RwLock; /// /// static LOCK: RwLock<i32> = RwLock::const_with_max_readers(5, 1024); /// ``` /// /// #...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
361
420
tokio-rs/tokio:tokio/src/sync/rwlock.rs:11
/// lock attempt is made, and then a subsequent read lock attempt is made /// by the current task. /// /// Returns an RAII guard which will drop this read access of the `RwLock` /// when dropped. /// /// # Cancel safety /// /// This method uses a queue to fairly distribute locks in the o...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
401
460
tokio-rs/tokio:tokio/src/sync/rwlock.rs:12
// handle to it through the Arc, which means that this can never happen. unreachable!() }); RwLockReadGuard { s: &self.s, data: self.c.get(), marker: PhantomData, #[cfg(all(tokio_unstable, feature = "tracing"))] ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
441
500
tokio-rs/tokio:tokio/src/sync/rwlock.rs:15
/// 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_owned().await; /// assert_eq!(*n, 1); /// /// tokio::spawn(a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
561
620
tokio-rs/tokio:tokio/src/sync/rwlock.rs:16
#[cfg(all(tokio_unstable, feature = "tracing"))] let acquire_fut = trace::async_op( move || acquire_fut, resource_span, "RwLock::read_owned", "poll", false, ); #[allow(clippy::let_and_return)] // this lint triggers when disabling traci...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
601
660
tokio-rs/tokio:tokio/src/sync/rwlock.rs:17
/// async fn main() { /// let lock = Arc::new(RwLock::new(1)); /// let c_lock = lock.clone(); /// /// let v = lock.try_read().unwrap(); /// assert_eq!(*v, 1); /// /// tokio::spawn(async move { /// // While main has an active read lock, we acquire one too. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
641
700
tokio-rs/tokio:tokio/src/sync/rwlock.rs:18
Ok(guard) } /// Attempts to acquire this `RwLock` with shared read access. /// /// If the access couldn't be acquired immediately, returns [`TryLockError`]. /// Otherwise, an RAII guard is returned which will release read access /// when dropped. /// /// This method is identical to [`Rw...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
681
740
tokio-rs/tokio:tokio/src/sync/rwlock.rs:19
/// } /// ``` pub fn try_read_owned(self: Arc<Self>) -> Result<OwnedRwLockReadGuard<T>, TryLockError> { match self.s.try_acquire(1) { Ok(permit) => permit, Err(TryAcquireError::NoPermits) => return Err(TryLockError(())), Err(TryAcquireError::Closed) => unreachable!(),...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
721
780
tokio-rs/tokio:tokio/src/sync/rwlock.rs:20
/// This method uses a queue to fairly distribute locks in the order they /// were requested. Cancelling a call to `write` makes you lose your place /// in the queue. /// /// # Examples /// /// ``` /// use tokio::sync::RwLock; /// /// #[tokio::main] /// async fn main() { /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
761
820
tokio-rs/tokio:tokio/src/sync/rwlock.rs:21
"RwLock::write", "poll", false, ); #[allow(clippy::let_and_return)] // this lint triggers when disabling tracing let guard = acquire_fut.await; #[cfg(all(tokio_unstable, feature = "tracing"))] self.resource_span.in_scope(|| { tracing::trace!(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
801
860
tokio-rs/tokio:tokio/src/sync/rwlock.rs:23
/// /// This method is identical to [`RwLock::write`], except that the returned /// guard references the `RwLock` with an [`Arc`] rather than by borrowing /// it. Therefore, the `RwLock` must be wrapped in an `Arc` to call this /// method, and the guard will live for the `'static` lifetime, as it keeps ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
881
940
tokio-rs/tokio:tokio/src/sync/rwlock.rs:24
}); OwnedRwLockWriteGuard { #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: self.resource_span.clone(), permits_acquired: self.mr, data: self.c.get(), lock: self, _p: PhantomData, } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
921
980
tokio-rs/tokio:tokio/src/sync/rwlock.rs:25
/// when dropped. /// /// [`TryLockError`]: TryLockError /// /// # Examples /// /// ``` /// use tokio::sync::RwLock; /// /// #[tokio::main] /// async fn main() { /// let rw = RwLock::new(1); /// /// let v = rw.read().await; /// assert_eq!(*v, 1); /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
961
1,020
tokio-rs/tokio:tokio/src/sync/rwlock.rs:26
write_locked = true, write_locked.op = "override", ) }); Ok(guard) } /// Attempts to acquire this `RwLock` with exclusive write access. /// /// If the access couldn't be acquired immediately, returns [`TryLockError`]. /// Otherwise, an RAII guard is returned...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
1,001
1,060
tokio-rs/tokio:tokio/src/sync/rwlock.rs:27
match self.s.try_acquire(self.mr as usize) { Ok(permit) => permit, Err(TryAcquireError::NoPermits) => return Err(TryLockError(())), Err(TryAcquireError::Closed) => unreachable!(), } let guard = OwnedRwLockWriteGuard { #[cfg(all(tokio_unstable, feature = "...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
1,041
1,100
tokio-rs/tokio:tokio/src/sync/rwlock.rs:28
/// let n = lock.get_mut(); /// *n = 2; /// } /// ``` pub fn get_mut(&mut self) -> &mut T { unsafe { // Safety: This is https://github.com/rust-lang/rust/pull/76936 &mut *self.c.get() } } /// Consumes the lock, returning the underlying data. p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
30d25ccb8bc91ca811773ee243e71e31772275d2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/30d25ccb8bc91ca811773ee243e71e31772275d2/tokio/src/sync/rwlock.rs
1,081
1,128
tokio-rs/tokio:tokio/src/sync/rwlock.rs:7
let s = resource_span.in_scope(|| Semaphore::new(MAX_READS as usize)); #[cfg(any(not(tokio_unstable), not(feature = "tracing")))] let s = Semaphore::new(MAX_READS as usize); RwLock { mr: MAX_READS, c: UnsafeCell::new(value), s, #[cfg(all(tokio_un...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
241
300
tokio-rs/tokio:tokio/src/sync/rwlock.rs:8
let location = std::panic::Location::caller(); let resource_span = tracing::trace_span!( parent: None, "runtime.resource", concrete_type = "RwLock", kind = "Sync", loc.file = location.file(), loc.line = location...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
281
340
tokio-rs/tokio:tokio/src/sync/rwlock.rs:9
c: UnsafeCell::new(value), s, #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span, } } /// Creates a new instance of an `RwLock<T>` which is unlocked. /// /// When using the `tracing` [unstable feature], a `RwLock` created with /// `const_new` ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
321
380
tokio-rs/tokio:tokio/src/sync/rwlock.rs:10
/// /// # Examples /// /// ``` /// use tokio::sync::RwLock; /// /// static LOCK: RwLock<i32> = RwLock::const_with_max_readers(5, 1024); /// ``` #[cfg(not(all(loom, test)))] pub const fn const_with_max_readers(value: T, max_reads: u32) -> RwLock<T> where T: Sized, { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
361
420
tokio-rs/tokio:tokio/src/sync/rwlock.rs:11
/// /// This method uses a queue to fairly distribute locks in the order they /// were requested. Cancelling a call to `read` makes you lose your place in /// the queue. /// /// # Examples /// /// ``` /// use std::sync::Arc; /// use tokio::sync::RwLock; /// /// # #[tokio::mai...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
401
460
tokio-rs/tokio:tokio/src/sync/rwlock.rs:12
marker: PhantomData, #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: self.resource_span.clone(), } }; #[cfg(all(tokio_unstable, feature = "tracing"))] let acquire_fut = trace::async_op( move || acquire_fut, self...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
441
500
tokio-rs/tokio:tokio/src/sync/rwlock.rs:15
/// # async fn main() { /// let lock = Arc::new(RwLock::new(1)); /// let c_lock = lock.clone(); /// /// let n = lock.read_owned().await; /// assert_eq!(*n, 1); /// /// tokio::spawn(async move { /// // While main has an active read lock, we acquire one too. /// let r = c_lock....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
561
620
tokio-rs/tokio:tokio/src/sync/rwlock.rs:16
resource_span, "RwLock::read_owned", "poll", false, ); #[allow(clippy::let_and_return)] // this lint triggers when disabling tracing let guard = acquire_fut.await; #[cfg(all(tokio_unstable, feature = "tracing"))] guard.resource_span.in_scope(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
601
660
tokio-rs/tokio:tokio/src/sync/rwlock.rs:17
/// let v = lock.try_read().unwrap(); /// assert_eq!(*v, 1); /// /// tokio::spawn(async move { /// // While main has an active read lock, we acquire one too. /// let n = c_lock.read().await; /// assert_eq!(*n, 1); /// }).await.expect("The spawned task has panicked"); /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
641
700
tokio-rs/tokio:tokio/src/sync/rwlock.rs:18
/// Attempts to acquire this `RwLock` with shared read access. /// /// If the access couldn't be acquired immediately, returns [`TryLockError`]. /// Otherwise, an RAII guard is returned which will release read access /// when dropped. /// /// This method is identical to [`RwLock::try_read`], exc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
681
740
tokio-rs/tokio:tokio/src/sync/rwlock.rs:19
Ok(permit) => permit, Err(TryAcquireError::NoPermits) => return Err(TryLockError(())), Err(TryAcquireError::Closed) => unreachable!(), } let guard = OwnedRwLockReadGuard { #[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: self.resource_span....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
721
780
tokio-rs/tokio:tokio/src/sync/rwlock.rs:20
/// # Examples /// /// ``` /// use tokio::sync::RwLock; /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { /// let lock = RwLock::new(1); /// /// let mut n = lock.write().await; /// *n = 2; /// # } /// ``` pub async fn write(&self) -> RwLockWr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
761
820
tokio-rs/tokio:tokio/src/sync/rwlock.rs:23
/// guard references the `RwLock` with an [`Arc`] rather than by borrowing /// it. Therefore, the `RwLock` must be wrapped in an `Arc` to call this /// method, and the guard will live for the `'static` lifetime, as it keeps /// the `RwLock` alive by holding an `Arc`. /// /// Returns an RAII guard wh...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
881
940
tokio-rs/tokio:tokio/src/sync/rwlock.rs:24
#[cfg(all(tokio_unstable, feature = "tracing"))] resource_span: self.resource_span.clone(), permits_acquired: self.mr, data: self.c.get(), lock: self, _p: PhantomData, } }; #[cfg(all(tokio_unstable, feature = "t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/sync/rwlock.rs
MIT
e65040f061008ca5a94d21721aa8b544c078c606
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e65040f061008ca5a94d21721aa8b544c078c606/tokio/src/sync/rwlock.rs
921
980