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/mpsc/unbounded.rs:8 | let mut curr = self.chan.semaphore().load(Acquire);
loop {
if curr & 1 == 1 {
return false;
}
if curr == usize::MAX ^ 1 {
// Overflowed the ref count. There is no safe way to recover, so
// abort the process. In practice, this... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 4daeea8cad1ce8e67946bc0e17d499ab304b5ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4daeea8cad1ce8e67946bc0e17d499ab304b5ca2/tokio/src/sync/mpsc/unbounded.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:10 | ///
/// drop(rx);
/// assert!(tx.is_closed());
/// assert!(tx2.is_closed());
/// ```
pub fn is_closed(&self) -> bool {
self.chan.is_closed()
}
/// Returns `true` if senders belong to the same channel.
///
/// # Examples
///
/// ```
/// let (tx, rx) = tokio::sync:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 4daeea8cad1ce8e67946bc0e17d499ab304b5ca2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4daeea8cad1ce8e67946bc0e17d499ab304b5ca2/tokio/src/sync/mpsc/unbounded.rs | 361 | 385 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | /// let sync_code = thread::spawn(move || {
/// assert_eq!(Some(10), rx.blocking_recv());
/// });
///
/// let _ = tx.send(10);
/// sync_code.join().unwrap();
/// }
/// ```
#[cfg(feature = "sync")]
pub fn blocking_recv(&mut self) -> Option<T> {
crate::f... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 6f9a58621439e4ac13b367fbe7b861f0a210f0b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6f9a58621439e4ac13b367fbe7b861f0a210f0b1/tokio/src/sync/mpsc/unbounded.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:7 | /// If this method returns `Poll::Pending` due to a spurious failure, then
/// the `Waker` will be notified when the situation causing the spurious
/// failure has been resolved. Note that receiving such a wakeup does not
/// guarantee that the next call will succeed — it could fail with another
/// spu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 6f9a58621439e4ac13b367fbe7b861f0a210f0b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6f9a58621439e4ac13b367fbe7b861f0a210f0b1/tokio/src/sync/mpsc/unbounded.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:8 | let mut curr = self.chan.semaphore().load(Acquire);
loop {
if curr & 1 == 1 {
return false;
}
if curr == usize::MAX ^ 1 {
// Overflowed the ref count. There is no safe way to recover, so
// abort the process. In practice, this... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 6f9a58621439e4ac13b367fbe7b861f0a210f0b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6f9a58621439e4ac13b367fbe7b861f0a210f0b1/tokio/src/sync/mpsc/unbounded.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:10 | /// drop(rx);
/// assert!(tx.is_closed());
/// assert!(tx2.is_closed());
/// ```
pub fn is_closed(&self) -> bool {
self.chan.is_closed()
}
/// Returns `true` if senders belong to the same channel.
///
/// # Examples
///
/// ```
/// let (tx, rx) = tokio::sync::mpsc::u... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 6f9a58621439e4ac13b367fbe7b861f0a210f0b1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6f9a58621439e4ac13b367fbe7b861f0a210f0b1/tokio/src/sync/mpsc/unbounded.rs | 361 | 384 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | /// The channel receiver
chan: chan::Rx<T, Semaphore>,
}
impl<T> fmt::Debug for UnboundedReceiver<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("UnboundedReceiver")
.field("chan", &self.chan)
.finish()
}
}
/// Creates an unbounded mpsc c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | #[cfg(feature = "sync")]
pub fn blocking_recv(&mut self) -> Option<T> {
crate::future::block_on(self.recv())
}
/// Closes the receiving half of a channel, without dropping it.
///
/// This prevents any further messages from being sent on the channel while
/// still enabling the receiver... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/unbounded.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:7 | pub(crate) fn new(chan: chan::Tx<T, Semaphore>) -> UnboundedSender<T> {
UnboundedSender { chan }
}
/// Attempts to send a message on this `UnboundedSender` without blocking.
///
/// This method is not marked async because sending a message to an unbounded channel
/// never requires any form... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/unbounded.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:8 | }
match self
.chan
.semaphore()
.compare_exchange(curr, curr + 2, AcqRel, Acquire)
{
Ok(_) => return true,
Err(actual) => {
curr = actual;
}
}
}
}
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/unbounded.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:10 | ///
/// ```
/// let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<()>();
/// let tx2 = tx.clone();
/// assert!(tx.same_channel(&tx2));
///
/// let (tx3, rx3) = tokio::sync::mpsc::unbounded_channel::<()>();
/// assert!(!tx3.same_channel(&tx2));
/// ```
pub fn same_channel(&self, ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 03969cdae7674681d1b10926e6a56fbb8908dbb8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/sync/mpsc/unbounded.rs | 361 | 373 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | /// Closes the receiving half of a channel, without dropping it.
///
/// This prevents any further messages from being sent on the channel while
/// still enabling the receiver to drain messages that are buffered.
pub fn close(&mut self) {
self.chan.close();
}
/// Polls to receive the n... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | ddd33f2b05dacd81c5fcd3170c1c9e1b2abad0f5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ddd33f2b05dacd81c5fcd3170c1c9e1b2abad0f5/tokio/src/sync/mpsc/unbounded.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:7 | /// If the receive half of the channel is closed, either due to [`close`]
/// being called or the [`UnboundedReceiver`] having been dropped, this
/// function returns an error. The error includes the value passed to `send`.
///
/// [`close`]: UnboundedReceiver::close
/// [`UnboundedReceiver`]: Unbou... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | ddd33f2b05dacd81c5fcd3170c1c9e1b2abad0f5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ddd33f2b05dacd81c5fcd3170c1c9e1b2abad0f5/tokio/src/sync/mpsc/unbounded.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:9 | /// ```
pub async fn closed(&self) {
self.chan.closed().await
}
/// Checks if the channel has been closed. This happens when the
/// [`UnboundedReceiver`] is dropped, or when the
/// [`UnboundedReceiver::close`] method is called.
///
/// [`UnboundedReceiver`]: crate::sync::mpsc::Unb... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | ddd33f2b05dacd81c5fcd3170c1c9e1b2abad0f5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ddd33f2b05dacd81c5fcd3170c1c9e1b2abad0f5/tokio/src/sync/mpsc/unbounded.rs | 321 | 363 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::SendError;
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the
/// [`unbounded_channel`](unbounded_channel) function.
pub struct ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | b521cc26895c6331c8ced6be72f8b3d9947a9fb3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b521cc26895c6331c8ced6be72f8b3d9947a9fb3/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | /// The channel receiver
chan: chan::Rx<T, Semaphore>,
}
impl<T> fmt::Debug for UnboundedReceiver<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("UnboundedReceiver")
.field("chan", &self.chan)
.finish()
}
}
/// Creates an unbounded mpsc c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | e06b257e09b8ca1def4a3537a4448a31f2ede388 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e06b257e09b8ca1def4a3537a4448a31f2ede388/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:5 | }
/// Polls to receive the next message on this channel.
///
/// This method returns:
///
/// * `Poll::Pending` if no messages are available but the channel is not
/// closed.
/// * `Poll::Ready(Some(message))` if a message is available.
/// * `Poll::Ready(None)` if the channel ha... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | e06b257e09b8ca1def4a3537a4448a31f2ede388 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e06b257e09b8ca1def4a3537a4448a31f2ede388/tokio/src/sync/mpsc/unbounded.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | if !self.inc_num_messages() {
return Err(SendError(message));
}
self.chan.send(message);
Ok(())
}
fn inc_num_messages(&self) -> bool {
use std::process;
use std::sync::atomic::Ordering::{AcqRel, Acquire};
let mut curr = self.chan.semaphore().load(Ac... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | e06b257e09b8ca1def4a3537a4448a31f2ede388 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e06b257e09b8ca1def4a3537a4448a31f2ede388/tokio/src/sync/mpsc/unbounded.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:8 | /// let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<()>();
/// assert!(!tx.is_closed());
///
/// let tx2 = tx.clone();
/// assert!(!tx2.is_closed());
///
/// drop(rx);
/// assert!(tx.is_closed());
/// assert!(tx2.is_closed());
/// ```
pub fn is_closed(&self) -> bool {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | e06b257e09b8ca1def4a3537a4448a31f2ede388 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e06b257e09b8ca1def4a3537a4448a31f2ede388/tokio/src/sync/mpsc/unbounded.rs | 281 | 310 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:8 | /// let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<()>();
/// assert!(!tx.is_closed());
///
/// let tx2 = tx.clone();
/// assert!(!tx2.is_closed());
///
/// drop(rx);
/// assert!(tx.is_closed());
/// assert!(tx2.is_closed());
/// ```
pub fn is_closed(&self) -> bool {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 7f17822ed9943b7bd0703258268feb4f70edac51 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f17822ed9943b7bd0703258268feb4f70edac51/tokio/src/sync/mpsc/unbounded.rs | 281 | 294 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::SendError;
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the
/// [`unbounded_channel`](unbounded_channel) function.
pub struct ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 0b83b3b8cc61e9d911abec00c33ec3762b2a6437 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b83b3b8cc61e9d911abec00c33ec3762b2a6437/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | impl<T> fmt::Debug for UnboundedReceiver<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("UnboundedReceiver")
.field("chan", &self.chan)
.finish()
}
}
/// Creates an unbounded mpsc channel for communicating between asynchronous
/// tasks withou... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 0b83b3b8cc61e9d911abec00c33ec3762b2a6437 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b83b3b8cc61e9d911abec00c33ec3762b2a6437/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:5 | /// This method returns:
///
/// * `Poll::Pending` if no messages are available but the channel is not
/// closed.
/// * `Poll::Ready(Some(message))` if a message is available.
/// * `Poll::Ready(None)` if the channel has been closed and all messages
/// sent before it was closed have b... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 0b83b3b8cc61e9d911abec00c33ec3762b2a6437 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b83b3b8cc61e9d911abec00c33ec3762b2a6437/tokio/src/sync/mpsc/unbounded.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | self.chan.send(message);
Ok(())
}
fn inc_num_messages(&self) -> bool {
use std::process;
use std::sync::atomic::Ordering::{AcqRel, Acquire};
let mut curr = self.chan.semaphore().load(Acquire);
loop {
if curr & 1 == 1 {
return false;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 0b83b3b8cc61e9d911abec00c33ec3762b2a6437 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b83b3b8cc61e9d911abec00c33ec3762b2a6437/tokio/src/sync/mpsc/unbounded.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:8 | /// assert!(!tx2.is_closed());
///
/// drop(rx);
/// assert!(tx.is_closed());
/// assert!(tx2.is_closed());
/// ```
pub fn is_closed(&self) -> bool {
self.chan.is_closed()
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 0b83b3b8cc61e9d911abec00c33ec3762b2a6437 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b83b3b8cc61e9d911abec00c33ec3762b2a6437/tokio/src/sync/mpsc/unbounded.rs | 281 | 290 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | impl<T> fmt::Debug for UnboundedReceiver<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("UnboundedReceiver")
.field("chan", &self.chan)
.finish()
}
}
/// Creates an unbounded mpsc channel for communicating between asynchronous
/// tasks withou... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:4 | poll_fn(|cx| self.poll_recv(cx)).await
}
/// Blocking receive to call outside of asynchronous contexts.
///
/// # Panics
///
/// This function panics if called within an asynchronous execution
/// context.
///
/// # Examples
///
/// ```
/// use std::thread;
/// use t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/src/sync/mpsc/unbounded.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:5 | }
}
impl<T> UnboundedSender<T> {
pub(crate) fn new(chan: chan::Tx<T, Semaphore>) -> UnboundedSender<T> {
UnboundedSender { chan }
}
/// Attempts to send a message on this `UnboundedSender` without blocking.
///
/// This method is not marked async because sending a message to an unbounded c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/src/sync/mpsc/unbounded.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | if curr == usize::MAX ^ 1 {
// Overflowed the ref count. There is no safe way to recover, so
// abort the process. In practice, this should never happen.
process::abort()
}
match self
.chan
.semaphore()
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 8efa62013b551d5130791c3a79ce8ab5cb0b5abf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8efa62013b551d5130791c3a79ce8ab5cb0b5abf/tokio/src/sync/mpsc/unbounded.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:4 | poll_fn(|cx| self.poll_recv(cx)).await
}
/// Blocking receive to call outside of asynchronous contexts.
///
/// # Panics
///
/// This function panics if called within an asynchronous execution
/// context.
///
/// # Examples
///
/// ```
/// use std::thread;
/// use t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | a7833e300780546c091e606bb2e077542f2e2e4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7833e300780546c091e606bb2e077542f2e2e4e/tokio/src/sync/mpsc/unbounded.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:5 | }
}
#[cfg(feature = "stream")]
impl<T> crate::stream::Stream for UnboundedReceiver<T> {
type Item = T;
fn poll_next(mut self: std::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<T>> {
self.poll_recv(cx)
}
}
impl<T> UnboundedSender<T> {
pub(crate) fn new(chan: chan::Tx<T, Semaphore>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | a7833e300780546c091e606bb2e077542f2e2e4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7833e300780546c091e606bb2e077542f2e2e4e/tokio/src/sync/mpsc/unbounded.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | use std::sync::atomic::Ordering::{AcqRel, Acquire};
let mut curr = self.chan.semaphore().load(Acquire);
loop {
if curr & 1 == 1 {
return false;
}
if curr == usize::MAX ^ 1 {
// Overflowed the ref count. There is no safe way to recove... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | a7833e300780546c091e606bb2e077542f2e2e4e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7833e300780546c091e606bb2e077542f2e2e4e/tokio/src/sync/mpsc/unbounded.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::{SendError, TryRecvError};
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the
/// [`unbounded_channel`](unbounded_channel) funct... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | df20c162ae1308c07073b6a67c8ba4202f52d208 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df20c162ae1308c07073b6a67c8ba4202f52d208/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:4 | poll_fn(|cx| self.poll_recv(cx)).await
}
/// Blocking receive to call outside of asynchronous contexts.
///
/// # Panics
///
/// This function panics if called within an asynchronous execution
/// context.
///
/// # Examples
///
/// ```
/// use std::thread;
/// use t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | df20c162ae1308c07073b6a67c8ba4202f52d208 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df20c162ae1308c07073b6a67c8ba4202f52d208/tokio/src/sync/mpsc/unbounded.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:5 | /// This is useful for a flavor of "optimistic check" before deciding to
/// block on a receiver.
///
/// Compared with recv, this function has two failure cases instead of
/// one (one for disconnection, one for an empty buffer).
pub fn try_recv(&mut self) -> Result<T, TryRecvError> {
self.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | df20c162ae1308c07073b6a67c8ba4202f52d208 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df20c162ae1308c07073b6a67c8ba4202f52d208/tokio/src/sync/mpsc/unbounded.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | /// function returns an error. The error includes the value passed to `send`.
///
/// [`close`]: UnboundedReceiver::close
/// [`UnboundedReceiver`]: UnboundedReceiver
pub fn send(&self, message: T) -> Result<(), SendError<T>> {
if !self.inc_num_messages() {
return Err(SendError(messa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | df20c162ae1308c07073b6a67c8ba4202f52d208 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df20c162ae1308c07073b6a67c8ba4202f52d208/tokio/src/sync/mpsc/unbounded.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:8 | ///
/// [`UnboundedReceiver`]: crate::sync::mpsc::UnboundedReceiver
/// [`UnboundedReceiver::close`]: crate::sync::mpsc::UnboundedReceiver::close
///
/// ```
/// let (tx, rx) = tokio::sync::mpsc::unbounded_channel::<()>();
/// assert!(!tx.is_closed());
///
/// let tx2 = tx.clone();
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | df20c162ae1308c07073b6a67c8ba4202f52d208 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/df20c162ae1308c07073b6a67c8ba4202f52d208/tokio/src/sync/mpsc/unbounded.rs | 281 | 299 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:4 | poll_fn(|cx| self.poll_recv(cx)).await
}
/// Attempts to return a pending value on this receiver without blocking.
///
/// This method will never block the caller in order to wait for data to
/// become available. Instead, this will always return immediately with
/// a possible option of pendin... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | b5750825431afe6fe227a6fcf30a593b51ceff1b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5750825431afe6fe227a6fcf30a593b51ceff1b/tokio/src/sync/mpsc/unbounded.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:5 | }
/// Attempts to send a message on this `UnboundedSender` without blocking.
///
/// This method is not marked async because sending a message to an unbounded channel
/// never requires any form of waiting. Because of this, the `send` method can be
/// used in both synchronous and asynchronous code... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | b5750825431afe6fe227a6fcf30a593b51ceff1b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5750825431afe6fe227a6fcf30a593b51ceff1b/tokio/src/sync/mpsc/unbounded.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | match self
.chan
.semaphore()
.compare_exchange(curr, curr + 2, AcqRel, Acquire)
{
Ok(_) => return true,
Err(actual) => {
curr = actual;
}
}
}
}
/// Completes when... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | b5750825431afe6fe227a6fcf30a593b51ceff1b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5750825431afe6fe227a6fcf30a593b51ceff1b/tokio/src/sync/mpsc/unbounded.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:7 | /// );
//// println!("Receiver dropped");
/// }
/// ```
pub async fn closed(&self) {
self.chan.closed().await
}
/// Checks if the channel has been closed. This happens when the
/// [`UnboundedReceiver`] is dropped, or when the
/// [`UnboundedReceiver::close`] method is ca... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | b5750825431afe6fe227a6fcf30a593b51ceff1b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b5750825431afe6fe227a6fcf30a593b51ceff1b/tokio/src/sync/mpsc/unbounded.rs | 241 | 269 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | match self
.chan
.semaphore()
.compare_exchange(curr, curr + 2, AcqRel, Acquire)
{
Ok(_) => return true,
Err(actual) => {
curr = actual;
}
}
}
}
/// Completes when... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 078d0a2ebc4d4f88cb6bce05c8ac4f5038dae9be | github | async-runtime | https://github.com/tokio-rs/tokio/blob/078d0a2ebc4d4f88cb6bce05c8ac4f5038dae9be/tokio/src/sync/mpsc/unbounded.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:7 | /// );
//// println!("Receiver dropped");
/// }
/// ```
pub async fn closed(&mut self) {
self.chan.closed().await
}
/// Checks if the channel has been closed. This happens when the
/// [`UnboundedReceiver`] is dropped, or when the
/// [`UnboundedReceiver::close`] method i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 078d0a2ebc4d4f88cb6bce05c8ac4f5038dae9be | github | async-runtime | https://github.com/tokio-rs/tokio/blob/078d0a2ebc4d4f88cb6bce05c8ac4f5038dae9be/tokio/src/sync/mpsc/unbounded.rs | 241 | 269 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | match self
.chan
.semaphore()
.compare_exchange(curr, curr + 2, AcqRel, Acquire)
{
Ok(_) => return true,
Err(actual) => {
curr = actual;
}
}
}
}
/// Completes when... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 55d932a21fd4c5fa298ca3cfdcb1388dbbf43dd0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/55d932a21fd4c5fa298ca3cfdcb1388dbbf43dd0/tokio/src/sync/mpsc/unbounded.rs | 201 | 248 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:5 | }
/// Attempts to send a message on this `UnboundedSender` without blocking.
///
/// This method is not marked async because sending a message to an unbounded channel
/// never requires any form of waiting. Because of this, the `send` method can be
/// used in both synchronous and asynchronous code... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | cf025ba45f68934ae2138bb75ee2a5ee50506d1b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/sync/mpsc/unbounded.rs | 161 | 213 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | match self
.chan
.semaphore()
.compare_exchange(curr, curr + 2, AcqRel, Acquire)
{
Ok(_) => return true,
Err(actual) => {
curr = actual;
}
}
}
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | cf025ba45f68934ae2138bb75ee2a5ee50506d1b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/sync/mpsc/unbounded.rs | 201 | 213 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | impl<T> fmt::Debug for UnboundedReceiver<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("UnboundedReceiver")
.field("chan", &self.chan)
.finish()
}
}
/// Creates an unbounded mpsc channel for communicating between asynchronous
/// tasks withou... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | be7462e50fe21c3eea578e12765f501e1157072b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be7462e50fe21c3eea578e12765f501e1157072b/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:4 | use crate::future::poll_fn;
poll_fn(|cx| self.poll_recv(cx)).await
}
/// Attempts to return a pending value on this receiver without blocking.
///
/// This method will never block the caller in order to wait for data to
/// become available. Instead, this will always return immediately wit... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | be7462e50fe21c3eea578e12765f501e1157072b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be7462e50fe21c3eea578e12765f501e1157072b/tokio/src/sync/mpsc/unbounded.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:5 | UnboundedSender { chan }
}
/// Attempts to send a message on this `UnboundedSender` without blocking.
///
/// This method is not marked async because sending a message to an unbounded channel
/// never requires any form of waiting. Because of this, the `send` method can be
/// used in both sync... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | be7462e50fe21c3eea578e12765f501e1157072b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/be7462e50fe21c3eea578e12765f501e1157072b/tokio/src/sync/mpsc/unbounded.rs | 161 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::{SendError, TryRecvError};
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the
/// [`unbounded_channel`](unbounded_channel) funct... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 3db22e29d19eba5b2a85e78f4ae8330d3edf6776 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3db22e29d19eba5b2a85e78f4ae8330d3edf6776/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | impl<T> fmt::Debug for UnboundedReceiver<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("UnboundedReceiver")
.field("chan", &self.chan)
.finish()
}
}
/// Creates an unbounded mpsc channel for communicating between asynchronous
/// tasks.
///
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 3db22e29d19eba5b2a85e78f4ae8330d3edf6776 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3db22e29d19eba5b2a85e78f4ae8330d3edf6776/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:4 | use crate::future::poll_fn;
poll_fn(|cx| self.poll_recv(cx)).await
}
/// Attempts to return a pending value on this receiver without blocking.
///
/// This method will never block the caller in order to wait for data to
/// become available. Instead, this will always return immediately wit... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | d65bf3805be376505f5c2fb0724cec8917dfb813 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d65bf3805be376505f5c2fb0724cec8917dfb813/tokio/src/sync/mpsc/unbounded.rs | 121 | 176 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:5 | UnboundedSender { chan }
}
/// Attempts to send a message on this `UnboundedSender` without blocking.
///
/// If the receive half of the channel is closed, either due to [`close`]
/// being called or the [`UnboundedReceiver`] having been dropped,
/// the function returns an error. The error inc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | d65bf3805be376505f5c2fb0724cec8917dfb813 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d65bf3805be376505f5c2fb0724cec8917dfb813/tokio/src/sync/mpsc/unbounded.rs | 161 | 176 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:4 | use crate::future::poll_fn;
poll_fn(|cx| self.poll_recv(cx)).await
}
/// Attempts to return a pending value on this receiver without blocking.
///
/// This method will never block the caller in order to wait for data to
/// become available. Instead, this will always return immediately wit... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/mpsc/unbounded.rs | 121 | 169 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::{SendError, TryRecvError};
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the
/// [`unbounded_channel`](unbounded_channel) funct... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 7b53b7b659fe1feeb30e768cad8fdadf9531beb6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b53b7b659fe1feeb30e768cad8fdadf9531beb6/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | impl<T> fmt::Debug for UnboundedReceiver<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("UnboundedReceiver")
.field("chan", &self.chan)
.finish()
}
}
/// Create an unbounded mpsc channel for communicating between asynchronous
/// tasks.
///
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 7b53b7b659fe1feeb30e768cad8fdadf9531beb6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7b53b7b659fe1feeb30e768cad8fdadf9531beb6/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::{SendError, TryRecvError};
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the
/// [`unbounded_channel`](fn.unbounded_channel.htm... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 4c645866ef4ea5b0ef8c7852281a09b2f96d969b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4c645866ef4ea5b0ef8c7852281a09b2f96d969b/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:4 | use crate::future::poll_fn;
poll_fn(|cx| self.poll_recv(cx)).await
}
/// Attempts to return a pending value on this receiver without blocking.
///
/// This method will never block the caller in order to wait for data to
/// become available. Instead, this will always return immediately wit... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 975576952f33c64e4faaa616f67ae9d6b596e4aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/975576952f33c64e4faaa616f67ae9d6b596e4aa/tokio/src/sync/mpsc/unbounded.rs | 121 | 169 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::sync::mpsc::chan;
use crate::sync::mpsc::error::SendError;
use std::fmt;
use std::task::{Context, Poll};
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the
/// [`unbounded_channel`](fn.unbounded_channel.html) function.
pub... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:4 | use crate::future::poll_fn;
poll_fn(|cx| self.poll_recv(cx)).await
}
/// Closes the receiving half of a channel, without dropping it.
///
/// This prevents any further messages from being sent on the channel while
/// still enabling the receiver to drain messages that are buffered.
pub... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/mpsc/unbounded.rs | 121 | 154 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::sync::mpsc::chan;
use std::fmt;
use std::task::{Context, Poll};
use std::pin::Pin;
/// Send values to the associated `UnboundedReceiver`.
///
/// Instances are created by the
/// [`unbounded_channel`](fn.unbounded_channel.html) function.
pub struct UnboundedSend... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/unbounded.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:2 | impl<T> fmt::Debug for UnboundedReceiver<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("UnboundedReceiver")
.field("chan", &self.chan)
.finish()
}
}
/// Error returned by the `UnboundedSender`.
#[derive(Debug)]
pub struct UnboundedSendError((... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/unbounded.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:3 | /// No capacity
type Semaphore = AtomicUsize;
impl<T> UnboundedReceiver<T> {
pub(crate) fn new(chan: chan::Rx<T, Semaphore>) -> UnboundedReceiver<T> {
UnboundedReceiver { chan }
}
#[doc(hidden)] // TODO: remove
pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
self... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/unbounded.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:4 | ///
/// #[tokio::main]
/// async fn main() {
/// let (mut tx, mut rx) = mpsc::unbounded_channel();
///
/// tx.try_send("hello").unwrap();
/// tx.try_send("world").unwrap();
///
/// assert_eq!(Some("hello"), rx.recv().await);
/// assert_eq!(Some("world"), rx.recv()... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/unbounded.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:5 | /// Attempts to send a message on this `UnboundedSender` without blocking.
pub fn try_send(&mut self, message: T) -> Result<(), UnboundedTrySendError<T>> {
self.chan.try_send(message)?;
Ok(())
}
}
impl<T> futures_sink::Sink<T> for UnboundedSender<T> {
type Error = UnboundedSendError;
f... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/unbounded.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mpsc/unbounded.rs:6 | /// Get the inner value.
pub fn into_inner(self) -> T {
self.0
}
}
impl<T: fmt::Debug> fmt::Display for UnboundedTrySendError<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "channel closed")
}
}
impl<T: fmt::Debug> ::std::error::Error for UnboundedTrySend... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mpsc/unbounded.rs | MIT | a6253ed05a1e0d14bc64915f5937c29092df9497 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a6253ed05a1e0d14bc64915f5937c29092df9497/tokio/src/sync/mpsc/unbounded.rs | 201 | 230 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:4 | ///
/// Note that in contrast to [`std::sync::Mutex`], this implementation does not
/// poison the mutex when a thread holding the [`MutexGuard`] panics. In such a
/// case, the mutex will be unlocked. If the panic is caught, this might leave
/// the data protected by the mutex in an inconsistent state.
///
/// [`Mutex... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:5 | /// This guard is only available from a `Mutex` that is wrapped in an [`Arc`]. It
/// is identical to `MutexGuard`, except that rather than borrowing the `Mutex`,
/// it clones the `Arc`, incrementing the reference count. This means that
/// unlike `MutexGuard`, it will have the `'static` lifetime.
///
/// As long as y... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:6 | /// A owned handle to a held `Mutex` that has had a function applied to it via
/// [`OwnedMutexGuard::map`].
///
/// This can be used to hold a subfield of the protected data.
///
/// [`OwnedMutexGuard::map`]: method@OwnedMutexGuard::map
#[clippy::has_significant_drop]
#[must_use = "if unused the Mutex will immediately... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:7 | s: &'a semaphore::Semaphore,
data: *mut T,
}
/// A helper type used when taking apart a `OwnedMappedMutexGuard` without running
/// its Drop implementation.
#[allow(dead_code)] // Unused fields are still used in Drop.
struct OwnedMappedMutexGuardInner<T: ?Sized, U: ?Sized> {
#[cfg(all(tokio_unstable, feature =... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:8 | /// `Mutex::try_lock` operation will only fail if the mutex is already locked.
///
/// `RwLock::try_read` operation will only fail if the lock is currently held
/// by an exclusive writer.
///
/// `RwLock::try_write` operation will only fail if the lock is currently held
/// by any reader or by an exclusive writer.
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:9 | check_send_sync_val(mutex.lock());
let arc_mutex = Arc::new(Mutex::new(1));
check_send_sync_val(arc_mutex.clone().lock_owned());
check_static_val(arc_mutex.lock_owned());
}
impl<T: ?Sized> Mutex<T> {
/// Creates a new lock in an unlocked state ready for use.
///
/// # Examples
///
/// `... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:10 | locked = false,
);
semaphore::Semaphore::new(1)
});
#[cfg(any(not(tokio_unstable), not(feature = "tracing")))]
let s = semaphore::Semaphore::new(1);
Self {
c: UnsafeCell::new(t),
s,
#[cfg(all(tokio_unstable, feature = "tracing... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:11 | s: semaphore::Semaphore::const_new(1),
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: tracing::Span::none(),
}
}
/// Locks this mutex, causing the current task to yield until the lock has
/// been acquired. When the lock has been acquired, function returns ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:12 | resource_span: self.resource_span.clone(),
}
};
#[cfg(all(tokio_unstable, feature = "tracing"))]
let acquire_fut = trace::async_op(
move || acquire_fut,
self.resource_span.clone(),
"Mutex::lock",
"poll",
false,
);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:16 | ///
/// # Examples
///
/// ```
/// use tokio::sync::Mutex;
/// use std::sync::Arc;
///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let mutex = Arc::new(Mutex::new(1));
///
/// let mut n = mutex.clone().lock_owned().await;
/// *n = 2;
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:17 | #[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(|| {
tracing::trace!(
target: "runtime::resource::state_update",
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:18 | /// ```
pub fn try_lock(&self) -> Result<MutexGuard<'_, T>, TryLockError> {
match self.s.try_acquire(1) {
Ok(()) => {
let guard = MutexGuard {
lock: self,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:19 | /// ```
pub fn get_mut(&mut self) -> &mut T {
self.c.get_mut()
}
/// Attempts to acquire the lock, and returns [`TryLockError`] if the lock
/// is currently held somewhere else.
///
/// This method is identical to [`Mutex::try_lock`], except that the
/// returned guard references t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:20 | tracing::trace!(
target: "runtime::resource::state_update",
locked = true,
);
});
Ok(guard)
}
Err(_) => Err(TryLockError(())),
}
}
/// Consumes the mutex, returning the underlyin... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:21 | impl<T> Default for Mutex<T>
where
T: Default,
{
fn default() -> Self {
Self::new(T::default())
}
}
impl<T: ?Sized> std::fmt::Debug for Mutex<T>
where
T: std::fmt::Debug,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut d = f.debug_struct("Mutex");
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 801 | 860 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:22 | ///
/// This is an associated function that needs to be used as `MutexGuard::map(...)`. A method
/// would interfere with methods of the same name on the contents of the locked data.
///
/// # Examples
///
/// ```
/// use tokio::sync::{Mutex, MutexGuard};
///
/// #[derive(Debug, Clon... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 841 | 900 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:23 | resource_span: inner.resource_span,
}
}
/// Attempts to make a new [`MappedMutexGuard`] for a component of the locked data. The
/// original guard is returned if the closure returns `None`.
///
/// This operation cannot fail as the [`MutexGuard`] passed in already locked the mutex.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 881 | 940 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:24 | F: FnOnce(&mut T) -> Option<&mut U>,
{
let data = match f(&mut *this) {
Some(data) => data as *mut U,
None => return Err(this),
};
let inner = this.skip_drop();
Ok(MappedMutexGuard {
s: &inner.lock.s,
data,
marker: PhantomDa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 921 | 980 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:25 | }
}
impl<T: ?Sized> Drop for MutexGuard<'_, T> {
fn drop(&mut self) {
self.lock.s.release(1);
#[cfg(all(tokio_unstable, feature = "tracing"))]
self.resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resource::state_update",
locked = f... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 961 | 1,020 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:26 | }
// === impl OwnedMutexGuard ===
impl<T: ?Sized> OwnedMutexGuard<T> {
fn skip_drop(self) -> OwnedMutexGuardInner<T> {
let me = mem::ManuallyDrop::new(self);
// SAFETY: This duplicates the values in every field of the guard, then
// forgets the originals, so in the end no value is duplicat... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 1,001 | 1,060 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:27 | /// *mapped = 2;
/// }
///
/// assert_eq!(Foo(2), *foo.lock().await);
/// # }
/// ```
///
/// [`OwnedMutexGuard`]: struct@OwnedMutexGuard
/// [`OwnedMappedMutexGuard`]: struct@OwnedMappedMutexGuard
#[inline]
pub fn map<U, F>(mut this: Self, f: F) -> OwnedMappedMutexGuard<T, U... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 1,041 | 1,100 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:28 | /// struct Foo(u32);
///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let foo = Arc::new(Mutex::new(Foo(1)));
///
/// {
/// let mut mapped = OwnedMutexGuard::try_map(foo.clone().lock_owned().await, |f| Some(&mut f.0))
/// .expect("should not fai... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 1,081 | 1,140 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:29 | /// use std::sync::Arc;
/// use tokio::sync::{Mutex, OwnedMutexGuard};
///
/// async fn unlock_and_relock(guard: OwnedMutexGuard<u32>) -> OwnedMutexGuard<u32> {
/// println!("1. contains: {:?}", *guard);
/// let mutex: Arc<Mutex<u32>> = OwnedMutexGuard::mutex(&guard).clone();
/// dro... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 1,121 | 1,180 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:30 | type Target = T;
fn deref(&self) -> &Self::Target {
unsafe { &*self.lock.c.get() }
}
}
impl<T: ?Sized> DerefMut for OwnedMutexGuard<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { &mut *self.lock.c.get() }
}
}
impl<T: ?Sized + fmt::Debug> fmt::Debug for OwnedMutexGuard<T> ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 1,161 | 1,220 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:31 | ///
/// This is an associated function that needs to be used as `MappedMutexGuard::map(...)`. A
/// method would interfere with methods of the same name on the contents of the locked data.
///
/// [`MappedMutexGuard`]: struct@MappedMutexGuard
#[inline]
pub fn map<U, F>(mut this: Self, f: F) -> M... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 1,201 | 1,260 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:32 | Ok(MappedMutexGuard {
s: inner.s,
data,
marker: PhantomData,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: inner.resource_span,
})
}
}
impl<'a, T: ?Sized> Drop for MappedMutexGuard<'a, T> {
fn drop(&mut self) {
self.s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 1,241 | 1,300 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:33 | }
}
impl<'a, T: ?Sized + fmt::Display> fmt::Display for MappedMutexGuard<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&**self, f)
}
}
// === impl OwnedMappedMutexGuard ===
impl<T: ?Sized, U: ?Sized> OwnedMappedMutexGuard<T, U> {
fn skip_drop(self) -> Owned... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 1,281 | 1,340 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:34 | let inner = this.skip_drop();
OwnedMappedMutexGuard {
data,
lock: inner.lock,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: inner.resource_span,
}
}
/// Attempts to make a new [`OwnedMappedMutexGuard`] for a component of the lock... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 1,321 | 1,380 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:35 | self.lock.s.release(1);
#[cfg(all(tokio_unstable, feature = "tracing"))]
self.resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resource::state_update",
locked = false,
);
});
}
}
impl<T: ?Sized, U: ?Sized> Deref for Owne... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/mutex.rs | 1,361 | 1,396 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:11 | s: semaphore::Semaphore::const_new(1),
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: tracing::Span::none(),
}
}
/// Locks this mutex, causing the current task to yield until the lock has
/// been acquired. When the lock has been acquired, function returns ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | a99a3518020e1c7ea6db6f9d2e7e567637a3d7e7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a99a3518020e1c7ea6db6f9d2e7e567637a3d7e7/tokio/src/sync/mutex.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:12 | resource_span: self.resource_span.clone(),
}
};
#[cfg(all(tokio_unstable, feature = "tracing"))]
let acquire_fut = trace::async_op(
move || acquire_fut,
self.resource_span.clone(),
"Mutex::lock",
"poll",
false,
);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | a99a3518020e1c7ea6db6f9d2e7e567637a3d7e7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a99a3518020e1c7ea6db6f9d2e7e567637a3d7e7/tokio/src/sync/mutex.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:16 | /// use tokio::sync::Mutex;
/// use std::sync::Arc;
///
/// #[tokio::main]
/// async fn main() {
/// let mutex = Arc::new(Mutex::new(1));
///
/// let mut n = mutex.clone().lock_owned().await;
/// *n = 2;
/// }
/// ```
///
/// [`Arc`]: std::sync::Arc
pub as... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | a99a3518020e1c7ea6db6f9d2e7e567637a3d7e7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a99a3518020e1c7ea6db6f9d2e7e567637a3d7e7/tokio/src/sync/mutex.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:17 | guard.resource_span.in_scope(|| {
tracing::trace!(
target: "runtime::resource::state_update",
locked = true,
);
});
guard
}
async fn acquire(&self) {
crate::trace::async_trace_leaf().await;
self.s.acquire(1).await.unwrap_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | a99a3518020e1c7ea6db6f9d2e7e567637a3d7e7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a99a3518020e1c7ea6db6f9d2e7e567637a3d7e7/tokio/src/sync/mutex.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/mutex.rs:18 | let guard = MutexGuard {
lock: self,
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: self.resource_span.clone(),
};
#[cfg(all(tokio_unstable, feature = "tracing"))]
self.resource_span.in_scope(||... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/mutex.rs | MIT | a99a3518020e1c7ea6db6f9d2e7e567637a3d7e7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a99a3518020e1c7ea6db6f9d2e7e567637a3d7e7/tokio/src/sync/mutex.rs | 681 | 740 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.