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:21 | ///
/// ```
/// use tokio::sync::oneshot;
///
/// use std::future::poll_fn;
///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let (mut tx, mut rx) = oneshot::channel::<()>();
///
/// tokio::spawn(async move {
/// rx.close();
/// });
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 927df0e9d936ef6995a6b9abedabc032b8ef655c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/927df0e9d936ef6995a6b9abedabc032b8ef655c/tokio/src/sync/oneshot.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:33 | #[cfg(all(tokio_unstable, feature = "tracing"))]
let res = ready!(trace_poll_op!("poll_recv", inner.poll_recv(cx))).map_err(Into::into);
#[cfg(any(not(tokio_unstable), not(feature = "tracing")))]
let res = ready!(inner.poll_recv(cx)).map_err(Into::into);
res
} e... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 927df0e9d936ef6995a6b9abedabc032b8ef655c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/927df0e9d936ef6995a6b9abedabc032b8ef655c/tokio/src/sync/oneshot.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:15 | let async_op_span = resource_span
.in_scope(|| tracing::trace_span!("runtime.resource.async_op", source = "Receiver::await"));
#[cfg(all(tokio_unstable, feature = "tracing"))]
let async_op_poll_span =
async_op_span.in_scope(|| tracing::trace_span!("runtime.resource.async_op.poll"));
let rx... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | d1e4db1018f9124d66d0cc9673b97606ba90bf86 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1e4db1018f9124d66d0cc9673b97606ba90bf86/tokio/src/sync/oneshot.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:35 | // Attempt to set the task
unsafe {
self.rx_task.set_task(cx);
}
// Update the state
state = State::set_rx_task(&self.state);
if state.is_complete() {
coop.made_progress();
match... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 009a2567d0376d96ff3b459c5581057ab5b11770 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/009a2567d0376d96ff3b459c5581057ab5b11770/tokio/src/sync/oneshot.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:36 | /// Calling this method concurrently on multiple threads will result in a
/// data race. The `VALUE_SENT` state bit is used to ensure that only the
/// sender *or* the receiver will call this method at a given point in time.
/// If `VALUE_SENT` is not set, then only the sender may call this method;
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 009a2567d0376d96ff3b459c5581057ab5b11770 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/009a2567d0376d96ff3b459c5581057ab5b11770/tokio/src/sync/oneshot.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:37 | if state.is_tx_task_set() {
unsafe {
self.tx_task.drop_task();
}
}
// SAFETY: we have `&mut self`, and therefore we have
// exclusive access to the value.
unsafe {
// Note: the assertion holds because if the value has been sent by send... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 009a2567d0376d96ff3b459c5581057ab5b11770 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/009a2567d0376d96ff3b459c5581057ab5b11770/tokio/src/sync/oneshot.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:38 | /// the sender.
const VALUE_SENT: usize = 0b00010;
const CLOSED: usize = 0b00100;
/// Indicates that a waker for the sending task has been set.
///
/// # Safety
///
/// If this bit is not set, the `tx_task` field may be uninitialized.
const TX_TASK_SET: usize = 0b01000;
impl State {
fn new() -> State {
St... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 009a2567d0376d96ff3b459c5581057ab5b11770 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/009a2567d0376d96ff3b459c5581057ab5b11770/tokio/src/sync/oneshot.rs | 1,481 | 1,540 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:39 | // the `RX_TASK_SET` flag is set. However, `loom` does not support
// fences yet.
match cell.compare_exchange_weak(
state,
state | VALUE_SENT,
Ordering::AcqRel,
Ordering::Acquire,
) {
Ok(_) => break,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 009a2567d0376d96ff3b459c5581057ab5b11770 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/009a2567d0376d96ff3b459c5581057ab5b11770/tokio/src/sync/oneshot.rs | 1,521 | 1,580 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:40 | fn set_tx_task(cell: &AtomicUsize) -> State {
let val = cell.fetch_or(TX_TASK_SET, AcqRel);
State(val | TX_TASK_SET)
}
fn unset_tx_task(cell: &AtomicUsize) -> State {
let val = cell.fetch_and(!TX_TASK_SET, AcqRel);
State(val & !TX_TASK_SET)
}
fn is_tx_task_set(self) -> ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 009a2567d0376d96ff3b459c5581057ab5b11770 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/009a2567d0376d96ff3b459c5581057ab5b11770/tokio/src/sync/oneshot.rs | 1,561 | 1,594 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:9 | #[derive(Debug)]
pub struct Receiver<T> {
inner: Option<Arc<Inner<T>>>,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: tracing::Span,
#[cfg(all(tokio_unstable, feature = "tracing"))]
async_op_span: tracing::Span,
#[cfg(all(tokio_unstable, feature = "tracing"))]
async_op_poll... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:10 | impl std::error::Error for RecvError {}
// ===== impl TryRecvError =====
impl fmt::Display for TryRecvError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TryRecvError::Empty => write!(fmt, "channel empty"),
TryRecvError::Closed ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:11 | rx_task: Task,
}
struct Task(UnsafeCell<MaybeUninit<Waker>>);
impl Task {
/// # Safety
///
/// The caller must do the necessary synchronization to ensure that
/// the [`Self::0`] contains the valid [`Waker`] during the call.
unsafe fn will_wake(&self, cx: &mut Context<'_>) -> bool {
unsafe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:12 | /// # Safety
///
/// The caller must do the necessary synchronization to ensure that
/// the [`Self::0`] contains the valid [`Waker`] during the call.
unsafe fn set_task(&self, cx: &mut Context<'_>) {
self.0.with_mut(|ptr| {
let ptr: *mut Waker = unsafe { (*ptr).as_mut_ptr() };
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:13 | /// });
///
/// match rx.await {
/// Ok(v) => println!("got = {:?}", v),
/// Err(_) => println!("the sender dropped"),
/// }
/// # }
/// ```
#[track_caller]
pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
#[cfg(all(tokio_unstable, feature = "tracing"))]
let resource_span = {
let location = std... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:14 | resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resource::state_update",
value_sent = false,
value_sent.op = "override",
)
});
resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resource::stat... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:15 | let rx = Receiver {
inner: Some(inner),
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span,
#[cfg(all(tokio_unstable, feature = "tracing"))]
async_op_span,
#[cfg(all(tokio_unstable, feature = "tracing"))]
async_op_poll_span,
};
(tx, rx)
}
imp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:16 | /// let (tx, rx) = oneshot::channel();
///
/// tokio::spawn(async move {
/// if let Err(_) = tx.send(3) {
/// println!("the receiver dropped");
/// }
/// });
///
/// match rx.await {
/// Ok(v) => println!("got = {:?}", v),
/// Err(_) => println!("the sende... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:18 | /// });
///
/// tx.closed().await;
/// println!("the receiver dropped");
/// # }
/// ```
///
/// Paired with select
///
/// ```
/// use tokio::sync::oneshot;
/// use tokio::time::{self, Duration};
///
/// async fn compute() -> String {
/// // Complex computati... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:19 | use std::future::poll_fn;
#[cfg(all(tokio_unstable, feature = "tracing"))]
let resource_span = self.resource_span.clone();
#[cfg(all(tokio_unstable, feature = "tracing"))]
let closed = trace::async_op(
|| poll_fn(|cx| self.poll_closed(cx)),
resource_span,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:21 | /// # async fn main() {
/// let (mut tx, mut rx) = oneshot::channel::<()>();
///
/// tokio::spawn(async move {
/// rx.close();
/// });
///
/// poll_fn(|cx| tx.poll_closed(cx)).await;
///
/// println!("the receiver dropped");
/// # }
/// ```
pub fn poll_closed(&mut sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:22 | }
}
}
if !state.is_tx_task_set() {
// Attempt to set the task
unsafe {
inner.tx_task.set_task(cx);
}
// Update the state
state = State::set_tx_task(&inner.state);
if state.is_closed() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:30 | /// }
/// # }
/// ```
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() {
// SAFETY: If `state.is_complete()` returns true, th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:31 | /// Blocking receive to call outside of asynchronous contexts.
///
/// # Panics
///
/// This function panics if called within an asynchronous execution
/// context.
///
/// # Examples
///
/// ```
/// # #[cfg(not(target_family = "wasm"))]
/// # {
/// use std::thread;
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:32 | let state = inner.close();
if state.is_complete() {
// SAFETY: we have ensured that the `VALUE_SENT` bit has been set,
// so only the receiver can access the value.
drop(unsafe { inner.consume_value() });
}
#[cfg(all(tokio_unstable, f... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:33 | } else {
panic!("called after complete");
};
self.inner = None;
Ready(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... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:34 | }
} else if state.is_closed() {
coop.made_progress();
Ready(Err(RecvError(())))
} else {
if state.is_rx_task_set() {
let will_notify = unsafe { self.rx_task.will_wake(cx) };
// Check if the task is still the same
if !wi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:35 | if state.is_complete() {
coop.made_progress();
match unsafe { self.consume_value() } {
Some(value) => Ready(Ok(value)),
None => Ready(Err(RecvError(()))),
}
} else {
Pending
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:36 | }
/// Returns true if there is a value. This function does not check `state`.
///
/// # Safety
///
/// Calling this method concurrently on multiple threads will result in a
/// data race. The `VALUE_SENT` state bit is used to ensure that only the
/// sender *or* the receiver will call this ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:37 | // exclusive access to the value.
unsafe {
// Note: the assertion holds because if the value has been sent by sender,
// we must ensure that the value must have been consumed by the receiver before
// dropping the `Inner`.
debug_assert!(self.consume_value().is_non... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:38 | ///
/// If this bit is not set, the `tx_task` field may be uninitialized.
const TX_TASK_SET: usize = 0b01000;
impl State {
fn new() -> State {
State(0)
}
fn is_complete(self) -> bool {
self.0 & VALUE_SENT == VALUE_SENT
}
fn set_complete(cell: &AtomicUsize) -> State {
// Th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 1,481 | 1,540 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:39 | ) {
Ok(_) => break,
Err(actual) => state = actual,
}
}
State(state)
}
fn is_rx_task_set(self) -> bool {
self.0 & RX_TASK_SET == RX_TASK_SET
}
fn set_rx_task(cell: &AtomicUsize) -> State {
let val = cell.fetch_or(RX_TASK_SET, A... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 1,521 | 1,580 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:40 | State(val & !TX_TASK_SET)
}
fn is_tx_task_set(self) -> bool {
self.0 & TX_TASK_SET == TX_TASK_SET
}
fn as_usize(self) -> usize {
self.0
}
fn load(cell: &AtomicUsize, order: Ordering) -> State {
let val = cell.load(order);
State(val)
}
}
impl fmt::Debug for... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/oneshot.rs | 1,561 | 1,587 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:10 | impl std::error::Error for RecvError {}
// ===== impl TryRecvError =====
impl fmt::Display for TryRecvError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TryRecvError::Empty => write!(fmt, "channel empty"),
TryRecvError::Closed ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:11 | rx_task: Task,
}
struct Task(UnsafeCell<MaybeUninit<Waker>>);
impl Task {
unsafe fn will_wake(&self, cx: &mut Context<'_>) -> bool {
self.with_task(|w| w.will_wake(cx.waker()))
}
unsafe fn with_task<F, R>(&self, f: F) -> R
where
F: FnOnce(&Waker) -> R,
{
self.0.with(|ptr| ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:12 | ///
/// 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 to receive the value.
///
/// Each handle can be used on separate tasks.
///
/// # Examples
///
/// ```
/// use tokio::sync::oneshot;
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:13 | loc.line = location.line(),
loc.col = location.column(),
);
resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resource::state_update",
tx_dropped = false,
tx_dropped.op = "override",
)
});
resource_spa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:14 | state: AtomicUsize::new(State::new().as_usize()),
value: UnsafeCell::new(None),
tx_task: Task(UnsafeCell::new(MaybeUninit::uninit())),
rx_task: Task(UnsafeCell::new(MaybeUninit::uninit())),
});
let tx = Sender {
inner: Some(inner.clone()),
#[cfg(all(tokio_unstable, featu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:16 | // is set).
// That bit is only set by the sender later on in this method, and
// calling this method consumes `self`. Therefore, if it was possible to
// call this method, we know that the `VALUE_SENT` bit is unset, and
// the receiver is not currently accessing the `Uns... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:18 | /// let (mut tx, rx) = oneshot::channel();
///
/// tokio::spawn(async move {
/// tokio::select! {
/// _ = tx.closed() => {
/// // The receiver dropped, no need to do any further work
/// }
/// value = compute() => {
/// // The send can ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:20 | /// to the most recent call will be scheduled to receive a wakeup.
///
/// [`Receiver`]: struct@crate::sync::oneshot::Receiver
/// [`close`]: fn@crate::sync::oneshot::Receiver::close
///
/// # Return value
///
/// This function returns:
///
/// * `Poll::Pending` if the channel is st... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:21 | let mut state = State::load(&inner.state, Acquire);
if state.is_closed() {
coop.made_progress();
return Ready(());
}
if state.is_tx_task_set() {
let will_notify = unsafe { inner.tx_task.will_wake(cx) };
if !will_notify {
state = ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:22 | }
}
impl<T> Drop for Sender<T> {
fn drop(&mut self) {
if let Some(inner) = self.inner.as_ref() {
inner.complete();
#[cfg(all(tokio_unstable, feature = "tracing"))]
self.resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resourc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:29 | /// }
/// # }
/// ```
///
/// `try_recv` when the sender dropped before sending a value
///
/// ```
/// use tokio::sync::oneshot;
/// use tokio::sync::oneshot::error::TryRecvError;
///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let (tx, mu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:30 | value_received.op = "override",
)
});
Ok(value)
}
None => Err(TryRecvError::Closed),
}
} else if state.is_closed() {
Err(TryRecvError::Closed)
} els... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:31 | /// let sync_code = thread::spawn(move || {
/// assert_eq!(Ok(10), rx.blocking_recv());
/// });
///
/// let _ = tx.send(10);
/// sync_code.join().unwrap();
/// }
/// # }
/// ```
#[track_caller]
#[cfg(feature = "sync")]
#[cfg_attr(docsrs, doc(alias = "r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:32 | impl<T> Future for Receiver<T> {
type Output = Result<T, RecvError>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
// If `inner` is `None`, then `poll()` has already completed.
#[cfg(all(tokio_unstable, feature = "tracing"))]
let _res_span = self.resour... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:33 | self.rx_task.with_task(Waker::wake_by_ref);
}
}
true
}
fn poll_recv(&self, cx: &mut Context<'_>) -> Poll<Result<T, RecvError>> {
ready!(crate::trace::trace_leaf(cx));
// Keep track of task budget
let coop = ready!(crate::task::coop::poll_proceed(cx));
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:34 | // `UnsafeCell`. Therefore, it is now safe for us to access the
// cell.
return match unsafe { self.consume_value() } {
Some(value) => Ready(Ok(value)),
None => Ready(Err(RecvError(()))),
};
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:35 | if prev.is_tx_task_set() && !prev.is_complete() {
unsafe {
self.tx_task.with_task(Waker::wake_by_ref);
}
}
prev
}
/// Consumes the value. This function does not check `state`.
///
/// # Safety
///
/// Calling this method concurrently on m... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/sync/oneshot.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:11 | rx_task: Task,
}
struct Task(UnsafeCell<MaybeUninit<Waker>>);
impl Task {
unsafe fn will_wake(&self, cx: &mut Context<'_>) -> bool {
self.with_task(|w| w.will_wake(cx.waker()))
}
unsafe fn with_task<F, R>(&self, f: F) -> R
where
F: FnOnce(&Waker) -> R,
{
self.0.with(|ptr| ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:12 | ///
/// 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 to receive the value.
///
/// Each handle can be used on separate tasks.
///
/// # Examples
///
/// ```
/// use tokio::sync::oneshot;
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:14 | state: AtomicUsize::new(State::new().as_usize()),
value: UnsafeCell::new(None),
tx_task: Task(UnsafeCell::new(MaybeUninit::uninit())),
rx_task: Task(UnsafeCell::new(MaybeUninit::uninit())),
});
let tx = Sender {
inner: Some(inner.clone()),
#[cfg(all(tokio_unstable, featu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:16 | // is set).
// That bit is only set by the sender later on in this method, and
// calling this method consumes `self`. Therefore, if it was possible to
// call this method, we know that the `VALUE_SENT` bit is unset, and
// the receiver is not currently accessing the `Uns... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:18 | /// let (mut tx, rx) = oneshot::channel();
///
/// tokio::spawn(async move {
/// tokio::select! {
/// _ = tx.closed() => {
/// // The receiver dropped, no need to do any further work
/// }
/// value = compute() => {
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:20 | /// to the most recent call will be scheduled to receive a wakeup.
///
/// [`Receiver`]: struct@crate::sync::oneshot::Receiver
/// [`close`]: fn@crate::sync::oneshot::Receiver::close
///
/// # Return value
///
/// This function returns:
///
/// * `Poll::Pending` if the channel is st... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:22 | }
}
impl<T> Drop for Sender<T> {
fn drop(&mut self) {
if let Some(inner) = self.inner.as_ref() {
inner.complete();
#[cfg(all(tokio_unstable, feature = "tracing"))]
self.resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resourc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:29 | /// }
/// }
/// ```
///
/// `try_recv` when the sender dropped before sending a value
///
/// ```
/// use tokio::sync::oneshot;
/// use tokio::sync::oneshot::error::TryRecvError;
///
/// #[tokio::main]
/// async fn main() {
/// let (tx, mut rx) = oneshot::channel:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:30 | value_received.op = "override",
)
});
Ok(value)
}
None => Err(TryRecvError::Closed),
}
} else if state.is_closed() {
Err(TryRecvError::Closed)
} els... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:31 | /// });
///
/// let _ = tx.send(10);
/// sync_code.join().unwrap();
/// }
/// ```
#[track_caller]
#[cfg(feature = "sync")]
#[cfg_attr(docsrs, doc(alias = "recv_blocking"))]
pub fn blocking_recv(self) -> Result<T, RecvError> {
crate::future::block_on(self)
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:32 | fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
// If `inner` is `None`, then `poll()` has already completed.
#[cfg(all(tokio_unstable, feature = "tracing"))]
let _res_span = self.resource_span.clone().entered();
#[cfg(all(tokio_unstable, feature = "tracin... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:33 | true
}
fn poll_recv(&self, cx: &mut Context<'_>) -> Poll<Result<T, RecvError>> {
ready!(crate::trace::trace_leaf(cx));
// Keep track of task budget
let coop = ready!(crate::task::coop::poll_proceed(cx));
// Load the state
let mut state = State::load(&self.state, Acquire... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:34 | Some(value) => Ready(Ok(value)),
None => Ready(Err(RecvError(()))),
};
} else {
unsafe { self.rx_task.drop_task() };
}
}
}
if !state.is_rx_task_set() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:35 | }
}
prev
}
/// Consumes the value. This function does not check `state`.
///
/// # Safety
///
/// Calling this method concurrently on multiple threads will result in a
/// data race. The `VALUE_SENT` state bit is used to ensure that only the
/// sender *or* the receiver... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:36 | impl<T> Drop for Inner<T> {
fn drop(&mut self) {
let state = State(mut_load(&mut self.state));
if state.is_rx_task_set() {
unsafe {
self.rx_task.drop_task();
}
}
if state.is_tx_task_set() {
unsafe {
self.tx_task.dr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:37 | ///
/// If this bit is not set, the `rx_task` field may be uninitialized.
const RX_TASK_SET: usize = 0b00001;
/// Indicates that a value has been stored in the channel's inner `UnsafeCell`.
///
/// # Safety
///
/// This bit controls which side of the channel is permitted to access the
/// `UnsafeCell`. If it is set, th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 1,441 | 1,500 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:38 | // access the `UnsafeCell` to take the value back out, so if a
// `poll_recv` or `try_recv` call is occurring concurrently, both
// threads may try to access the `UnsafeCell` if we were to set the
// `VALUE_SENT` bit on a closed channel.
let mut state = cell.load(Ordering::Relaxed);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 1,481 | 1,540 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:39 | self.0 & CLOSED == CLOSED
}
fn set_closed(cell: &AtomicUsize) -> State {
// Acquire because we want all later writes (attempting to poll) to be
// ordered after this.
let val = cell.fetch_or(CLOSED, Acquire);
State(val)
}
fn set_tx_task(cell: &AtomicUsize) -> State {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 383da873138934cef928d659cc5c0588d3c88423 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/383da873138934cef928d659cc5c0588d3c88423/tokio/src/sync/oneshot.rs | 1,521 | 1,564 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:27 | ///
/// ```
/// use tokio::sync::oneshot;
/// use tokio::sync::oneshot::error::TryRecvError;
///
/// #[tokio::main]
/// async fn main() {
/// let (tx, mut rx) = oneshot::channel::<()>();
///
/// drop(tx);
///
/// match rx.try_recv() {
/// // The channe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 17117b591e7a15f7913b529a5c6aa38a7b3c27e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17117b591e7a15f7913b529a5c6aa38a7b3c27e1/tokio/src/sync/oneshot.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:28 | None => Err(TryRecvError::Closed),
}
} else if state.is_closed() {
Err(TryRecvError::Closed)
} else {
// Not ready, this does not clear `inner`
return Err(TryRecvError::Empty);
}
} else {
Err(TryRecvE... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 17117b591e7a15f7913b529a5c6aa38a7b3c27e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17117b591e7a15f7913b529a5c6aa38a7b3c27e1/tokio/src/sync/oneshot.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:29 | /// ```
#[track_caller]
#[cfg(feature = "sync")]
#[cfg_attr(docsrs, doc(alias = "recv_blocking"))]
pub fn blocking_recv(self) -> Result<T, RecvError> {
crate::future::block_on(self)
}
}
impl<T> Drop for Receiver<T> {
fn drop(&mut self) {
if let Some(inner) = self.inner.as_ref() ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 17117b591e7a15f7913b529a5c6aa38a7b3c27e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17117b591e7a15f7913b529a5c6aa38a7b3c27e1/tokio/src/sync/oneshot.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:30 | let _ao_span = self.async_op_span.clone().entered();
#[cfg(all(tokio_unstable, feature = "tracing"))]
let _ao_poll_span = self.async_op_poll_span.clone().entered();
let ret = if let Some(inner) = self.as_ref().get_ref().inner.as_ref() {
#[cfg(all(tokio_unstable, feature = "tracing")... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 17117b591e7a15f7913b529a5c6aa38a7b3c27e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17117b591e7a15f7913b529a5c6aa38a7b3c27e1/tokio/src/sync/oneshot.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:31 | ready!(crate::trace::trace_leaf(cx));
// Keep track of task budget
let coop = ready!(crate::task::coop::poll_proceed(cx));
// Load the state
let mut state = State::load(&self.state, Acquire);
if state.is_complete() {
coop.made_progress();
match unsafe { ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 17117b591e7a15f7913b529a5c6aa38a7b3c27e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17117b591e7a15f7913b529a5c6aa38a7b3c27e1/tokio/src/sync/oneshot.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:32 | }
}
}
if !state.is_rx_task_set() {
// Attempt to set the task
unsafe {
self.rx_task.set_task(cx);
}
// Update the state
state = State::set_rx_task(&self.state);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 17117b591e7a15f7913b529a5c6aa38a7b3c27e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17117b591e7a15f7913b529a5c6aa38a7b3c27e1/tokio/src/sync/oneshot.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:33 | /// Consumes the value. This function does not check `state`.
///
/// # Safety
///
/// Calling this method concurrently on multiple threads will result in a
/// data race. The `VALUE_SENT` state bit is used to ensure that only the
/// sender *or* the receiver will call this method at a given poi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 17117b591e7a15f7913b529a5c6aa38a7b3c27e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17117b591e7a15f7913b529a5c6aa38a7b3c27e1/tokio/src/sync/oneshot.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:34 | unsafe {
// Note: the assertion holds because if the value has been sent by sender,
// we must ensure that the value must have been consumed by the receiver before
// dropping the `Inner`.
debug_assert!(self.consume_value().is_none());
}
}
}
impl<T: fmt::Debu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 17117b591e7a15f7913b529a5c6aa38a7b3c27e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17117b591e7a15f7913b529a5c6aa38a7b3c27e1/tokio/src/sync/oneshot.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:35 | /// If this bit is not set, the `tx_task` field may be uninitialized.
const TX_TASK_SET: usize = 0b01000;
impl State {
fn new() -> State {
State(0)
}
fn is_complete(self) -> bool {
self.0 & VALUE_SENT == VALUE_SENT
}
fn set_complete(cell: &AtomicUsize) -> State {
// This m... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 17117b591e7a15f7913b529a5c6aa38a7b3c27e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17117b591e7a15f7913b529a5c6aa38a7b3c27e1/tokio/src/sync/oneshot.rs | 1,361 | 1,420 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:36 | Ok(_) => break,
Err(actual) => state = actual,
}
}
State(state)
}
fn is_rx_task_set(self) -> bool {
self.0 & RX_TASK_SET == RX_TASK_SET
}
fn set_rx_task(cell: &AtomicUsize) -> State {
let val = cell.fetch_or(RX_TASK_SET, AcqRel);
Stat... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 17117b591e7a15f7913b529a5c6aa38a7b3c27e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17117b591e7a15f7913b529a5c6aa38a7b3c27e1/tokio/src/sync/oneshot.rs | 1,401 | 1,460 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:37 | }
fn is_tx_task_set(self) -> bool {
self.0 & TX_TASK_SET == TX_TASK_SET
}
fn as_usize(self) -> usize {
self.0
}
fn load(cell: &AtomicUsize, order: Ordering) -> State {
let val = cell.load(order);
State(val)
}
}
impl fmt::Debug for State {
fn fmt(&self, fmt... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 17117b591e7a15f7913b529a5c6aa38a7b3c27e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17117b591e7a15f7913b529a5c6aa38a7b3c27e1/tokio/src/sync/oneshot.rs | 1,441 | 1,466 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:25 | ///
/// #[tokio::main]
/// async fn main() {
/// let (tx, mut rx) = oneshot::channel();
///
/// match rx.try_recv() {
/// // The channel is currently empty
/// Err(TryRecvError::Empty) => {}
/// _ => unreachable!(),
/// }
///
/// // Sen... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/oneshot.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:26 | 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() {
// SAFETY: If `state.is_complete()` returns true, then the
// `VALUE_S... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/oneshot.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:27 | /// # Panics
///
/// This function panics if called within an asynchronous execution
/// context.
///
/// # Examples
///
/// ```
/// use std::thread;
/// use tokio::sync::oneshot;
///
/// #[tokio::main]
/// async fn main() {
/// let (tx, rx) = oneshot::channel::<u... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/oneshot.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:28 | }
#[cfg(all(tokio_unstable, feature = "tracing"))]
self.resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resource::state_update",
rx_dropped = true,
rx_dropped.op = "override",
)
});
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/oneshot.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:29 | }
}
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 {
self.rx_task.with_task(Waker::wake... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/oneshot.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:30 | let will_notify = unsafe { self.rx_task.will_wake(cx) };
// 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() {
// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/oneshot.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:31 | }
} else {
Pending
}
} else {
Pending
}
}
}
/// Called by `Receiver` to indicate that the value will never be received.
fn close(&self) -> State {
let prev = State::set_closed(&self.state);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/oneshot.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:32 | fn mut_load(this: &mut AtomicUsize) -> usize {
this.with_mut(|v| *v)
}
impl<T> Drop for Inner<T> {
fn drop(&mut self) {
let state = State(mut_load(&mut self.state));
if state.is_rx_task_set() {
unsafe {
self.rx_task.drop_task();
}
}
if s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/oneshot.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:33 | /// Indicates that a waker for the receiving task has been set.
///
/// # Safety
///
/// If this bit is not set, the `rx_task` field may be uninitialized.
const RX_TASK_SET: usize = 0b00001;
/// Indicates that a value has been stored in the channel's inner `UnsafeCell`.
///
/// # Safety
///
/// This bit controls which ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/oneshot.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:34 | // We don't want to set both the `VALUE_SENT` bit if the `CLOSED`
// bit is already set, because `VALUE_SENT` will tell the receiver that
// it's okay to access the inner `UnsafeCell`. Immediately after calling
// `set_complete`, if the channel was closed, the sender will _also_
// acces... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/oneshot.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:35 | State(val & !RX_TASK_SET)
}
fn is_closed(self) -> bool {
self.0 & CLOSED == CLOSED
}
fn set_closed(cell: &AtomicUsize) -> State {
// Acquire because we want all later writes (attempting to poll) to be
// ordered after this.
let val = cell.fetch_or(CLOSED, Acquire);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/oneshot.rs | 1,361 | 1,408 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:20 | /// to the most recent call will be scheduled to receive a wakeup.
///
/// [`Receiver`]: struct@crate::sync::oneshot::Receiver
/// [`close`]: fn@crate::sync::oneshot::Receiver::close
///
/// # Return value
///
/// This function returns:
///
/// * `Poll::Pending` if the channel is st... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/sync/oneshot.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:29 | }
}
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 {
self.rx_task.with_task(Waker::wake... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/sync/oneshot.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:18 | /// let (mut tx, rx) = oneshot::channel();
///
/// tokio::spawn(async move {
/// tokio::select! {
/// _ = tx.closed() => {
/// // The receiver dropped, no need to do any further work
/// }
/// value = compute() => {
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/sync/oneshot.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:20 | /// to the most recent call will be scheduled to receive a wakeup.
///
/// [`Receiver`]: struct@crate::sync::oneshot::Receiver
/// [`close`]: fn@crate::sync::oneshot::Receiver::close
///
/// # Return value
///
/// This function returns:
///
/// * `Poll::Pending` if the channel is st... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/sync/oneshot.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:27 | /// # Panics
///
/// This function panics if called within an asynchronous execution
/// context.
///
/// # Examples
///
/// ```
/// use std::thread;
/// use tokio::sync::oneshot;
///
/// #[tokio::main]
/// async fn main() {
/// let (tx, rx) = oneshot::channel::<u... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/sync/oneshot.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:28 | rx_dropped.op = "override",
)
});
}
}
}
impl<T> Future for Receiver<T> {
type Output = Result<T, RecvError>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
// If `inner` is `None`, then `poll()` has already completed.
#[c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/sync/oneshot.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:29 | if prev.is_closed() {
return false;
}
if prev.is_rx_task_set() {
// TODO: Consume waker?
unsafe {
self.rx_task.with_task(Waker::wake_by_ref);
}
}
true
}
fn poll_recv(&self, cx: &mut Context<'_>) -> Poll<Result<T, ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/sync/oneshot.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:30 | // Set the flag again so that the waker is released in drop
State::set_rx_task(&self.state);
coop.made_progress();
// SAFETY: If `state.is_complete()` returns true, then the
// `VALUE_SENT` bit has been set and the sender s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/sync/oneshot.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:31 | }
}
/// 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.tx_task.with_task(Waker::wake_by_ref);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/sync/oneshot.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:32 | unsafe {
self.rx_task.drop_task();
}
}
if state.is_tx_task_set() {
unsafe {
self.tx_task.drop_task();
}
}
}
}
impl<T: fmt::Debug> fmt::Debug for Inner<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/sync/oneshot.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/sync/oneshot.rs:33 | /// Indicates that a waker for the sending task has been set.
///
/// # Safety
///
/// If this bit is not set, the `tx_task` field may be uninitialized.
const TX_TASK_SET: usize = 0b01000;
impl State {
fn new() -> State {
State(0)
}
fn is_complete(self) -> bool {
self.0 & VALUE_SENT == VAL... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/oneshot.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/sync/oneshot.rs | 1,281 | 1,340 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.