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/task/state.rs:7
if next.is_final_ref() || (next.has_join_waker() && !next.is_join_interested()) { // The final reference to the task was dropped, the caller must free the // memory. Establish an acquire ordering. atomic::fence(Acquire); } next } /// Transition the state to ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/state.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/task/state.rs
241
300
tokio-rs/tokio:tokio/src/task/state.rs:8
} /// The join handle has completed by reading the output /// /// Returns a snapshot of the state **after** the transition. pub(super) fn complete_join_handle(&self) -> Snapshot { use crate::loom::sync::atomic; const DELTA: usize = JOIN_INTEREST; let prev = Snapshot(self.val.f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/state.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/task/state.rs
281
340
tokio-rs/tokio:tokio/src/task/state.rs:9
debug_assert!(prev & JOIN_INTEREST == JOIN_INTEREST); let next = (prev - JOIN_INTEREST) & !JOIN_WAKER; let res = self.val.compare_exchange(prev, next, AcqRel, Acquire); match res { Ok(_) => { return Ok(Snapshot(next)); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/state.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/task/state.rs
321
380
tokio-rs/tokio:tokio/src/task/state.rs:10
const MASK: usize = COMPLETE | CANCELLED; let mut prev = self.val.load(Acquire); loop { // Once the `COMPLETE` bit is set, it is never unset if prev & MASK != 0 { return Snapshot(prev); } debug_assert!(Snapshot(prev).has_join_waker()); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/state.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/task/state.rs
361
420
tokio-rs/tokio:tokio/src/task/state.rs:11
let prev = self.val.fetch_add(WAKER_ONE, Relaxed); // If the reference count overflowed, abort. if prev > isize::max_value() as usize { process::abort(); } } /// Returns `true` if the task should be released. pub(super) fn ref_dec(&self) -> bool { use crate::loo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/state.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/task/state.rs
401
460
tokio-rs/tokio:tokio/src/task/state.rs:12
pub(super) fn is_canceled(self) -> bool { self.0 & CANCELLED == CANCELLED } /// Used during normal runtime. pub(super) fn is_active(self) -> bool { self.0 & (COMPLETE | CANCELLED) == 0 } /// Used before dropping the task pub(super) fn is_terminal(self) -> bool { // When...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/state.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/task/state.rs
441
500
tokio-rs/tokio:tokio/src/task/state.rs:13
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { use std::sync::atomic::Ordering::SeqCst; let snapshot = Snapshot(self.val.load(SeqCst)); fmt.debug_struct("State") .field("snapshot", &snapshot) .finish() } } impl fmt::Debug for Snapshot { fn fmt(&se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/state.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/task/state.rs
481
505
tokio-rs/tokio:tokio/src/task/state.rs:2
/// Bits used by the waker ref count portion of the state. /// /// Ref counts only cover **wakers**. Other handles are tracked with other state /// bits. const WAKER_COUNT_MASK: usize = usize::MAX - LIFECYCLE_MASK; /// Number of positions to shift the ref count const WAKER_COUNT_SHIFT: usize = WAKER_COUNT_MASK.count_z...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/state.rs
MIT
19f1fc36bd567377bde4a2c6818c6b606d89d488
github
async-runtime
https://github.com/tokio-rs/tokio/blob/19f1fc36bd567377bde4a2c6818c6b606d89d488/tokio/src/task/state.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, mem, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The ma...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:2
$crate::__task_local_inner!($(#[$attr])* $vis $name, $t); $crate::task_local!($($rest)*); }; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[macro_export] macro_rules! __task_local_inner { ($(#[$...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:3
/// /// NUMBER.scope(1, async move { /// assert_eq!(NUMBER.get(), 1); /// }).await; /// /// NUMBER.scope(2, async move { /// assert_eq!(NUMBER.get(), 2); /// /// NUMBER.scope(3, async move { /// assert_eq!(NUMBER.get(), 3); /// }).await; /// }).await; /// # } /// ``` /// /// [`std::thread::Local...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/task_local.rs
81
140
tokio-rs/tokio:tokio/src/task/task_local.rs:4
/// /// NUMBER.scope(1, async move { /// println!("task local value: {}", NUMBER.get()); /// }).await; /// # } /// ``` /// /// [`with`]: fn@Self::with /// [`try_with`]: fn@Self::try_with pub fn scope<F>(&'static self, value: T, f: F) -> TaskLocalFuture<T, F> where F: ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/task_local.rs
121
180
tokio-rs/tokio:tokio/src/task/task_local.rs:5
/// }); /// # } /// ``` /// /// [`with`]: fn@Self::with /// [`try_with`]: fn@Self::try_with #[track_caller] pub fn sync_scope<F, R>(&'static self, value: T, f: F) -> R where F: FnOnce() -> R, { let mut value = Some(value); match self.scope_inner(&mut value, f)...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/task_local.rs
161
220
tokio-rs/tokio:tokio/src/task/task_local.rs:6
// then. self.local.inner.with(|inner| { let mut ref_mut = inner.borrow_mut(); mem::swap(self.slot, &mut *ref_mut); }); } } self.inner.try_with(|inner| { inner .try_borrow_mut() ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/task_local.rs
201
260
tokio-rs/tokio:tokio/src/task/task_local.rs:7
/// /// If the task-local with the associated key is not present, this /// method will return an `AccessError`. For a panicking variant, /// see `with`. pub fn try_with<F, R>(&'static self, f: F) -> Result<R, AccessError> where F: FnOnce(&T) -> R, { // If called after the thread-...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/task_local.rs
241
300
tokio-rs/tokio:tokio/src/task/task_local.rs:8
/// /// If the task-local with the associated key is not present, this /// method will return an `AccessError`. For a panicking variant, /// see `get`. pub fn try_get(&'static self) -> Result<T, AccessError> { self.try_with(|v| v.clone()) } } impl<T: 'static> fmt::Debug for LocalKey<T> { ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/task_local.rs
281
340
tokio-rs/tokio:tokio/src/task/task_local.rs:9
{ local: &'static LocalKey<T>, slot: Option<T>, #[pin] future: Option<F>, #[pin] _pinned: PhantomPinned, } impl<T: 'static, F> PinnedDrop for TaskLocalFuture<T, F> { fn drop(this: Pin<&mut Self>) { let this = this.project(); if mem...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/task_local.rs
321
380
tokio-rs/tokio:tokio/src/task/task_local.rs:10
/// /// ``` /// # async fn dox() { /// tokio::task_local! { /// static KEY: u32; /// } /// /// let fut = KEY.scope(42, async { /// // Do some async work /// }); /// /// let mut pinned = Box::pin(fut); /// /// // Complete the TaskLocalFuture /// let _ = pin...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/task_local.rs
361
420
tokio-rs/tokio:tokio/src/task/task_local.rs:11
let res = fut.poll(cx); if res.is_ready() { future_opt.set(None); } Some(res) } None => None, }); match res { Ok(Some(res)) => res, Ok(None) => panic!("`TaskLo...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/task_local.rs
401
460
tokio-rs/tokio:tokio/src/task/task_local.rs:12
} /// An error returned by [`LocalKey::try_with`](method@LocalKey::try_with). #[derive(Clone, Copy, Eq, PartialEq)] pub struct AccessError { _private: (), } impl fmt::Debug for AccessError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("AccessError").finish() } } impl...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/task_local.rs
441
488
tokio-rs/tokio:tokio/src/task/task_local.rs:7
/// /// If the task-local with the associated key is not present, this /// method will return an `AccessError`. For a panicking variant, /// see `with`. pub fn try_with<F, R>(&'static self, f: F) -> Result<R, AccessError> where F: FnOnce(&T) -> R, { // If called after the thread-...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
ccee1d44934b3b019e7fd6cbb0d0c96603cd097b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ccee1d44934b3b019e7fd6cbb0d0c96603cd097b/tokio/src/task/task_local.rs
241
300
tokio-rs/tokio:tokio/src/task/task_local.rs:8
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("LocalKey { .. }") } } pin_project! { /// A future that sets a value `T` of a task local for the future `F` during /// its execution. /// /// The value of the task-local must be `'static` and will be dropped on the /// com...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
ccee1d44934b3b019e7fd6cbb0d0c96603cd097b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ccee1d44934b3b019e7fd6cbb0d0c96603cd097b/tokio/src/task/task_local.rs
281
340
tokio-rs/tokio:tokio/src/task/task_local.rs:9
fn drop(this: Pin<&mut Self>) { let this = this.project(); if mem::needs_drop::<F>() && this.future.is_some() { // Drop the future while the task-local is set, if possible. Otherwise // the future is dropped normally when the `Option<F>` field drops. ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
ccee1d44934b3b019e7fd6cbb0d0c96603cd097b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ccee1d44934b3b019e7fd6cbb0d0c96603cd097b/tokio/src/task/task_local.rs
321
380
tokio-rs/tokio:tokio/src/task/task_local.rs:10
/// /// let mut pinned = Box::pin(fut); /// /// // Complete the TaskLocalFuture /// let _ = pinned.as_mut().await; /// /// // And here, we can take task local value /// let value = pinned.as_mut().take_value(); /// /// assert_eq!(value, Some(42)); /// # } /// ``` pub fn t...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
ccee1d44934b3b019e7fd6cbb0d0c96603cd097b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ccee1d44934b3b019e7fd6cbb0d0c96603cd097b/tokio/src/task/task_local.rs
361
420
tokio-rs/tokio:tokio/src/task/task_local.rs:11
Ok(Some(res)) => res, Ok(None) => panic!("`TaskLocalFuture` polled after completion"), Err(err) => err.panic(), } } } impl<T: 'static, F> fmt::Debug for TaskLocalFuture<T, F> where T: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// Format...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
ccee1d44934b3b019e7fd6cbb0d0c96603cd097b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ccee1d44934b3b019e7fd6cbb0d0c96603cd097b/tokio/src/task/task_local.rs
401
460
tokio-rs/tokio:tokio/src/task/task_local.rs:12
f.debug_struct("AccessError").finish() } } impl fmt::Display for AccessError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt("task-local value not set", f) } } impl Error for AccessError {} enum ScopeInnerErr { BorrowError, AccessError, } impl ScopeInnerErr...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
ccee1d44934b3b019e7fd6cbb0d0c96603cd097b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ccee1d44934b3b019e7fd6cbb0d0c96603cd097b/tokio/src/task/task_local.rs
441
478
tokio-rs/tokio:tokio/src/task/task_local.rs:7
/// /// If the task-local with the associated key is not present, this /// method will return an `AccessError`. For a panicking variant, /// see `with`. pub fn try_with<F, R>(&'static self, f: F) -> Result<R, AccessError> where F: FnOnce(&T) -> R, { // If called after the thread-...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
94db07b379092ac49527d98166dab43fc1197f27
github
async-runtime
https://github.com/tokio-rs/tokio/blob/94db07b379092ac49527d98166dab43fc1197f27/tokio/src/task/task_local.rs
241
300
tokio-rs/tokio:tokio/src/task/task_local.rs:8
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("LocalKey { .. }") } } pin_project! { /// A future that sets a value `T` of a task local for the future `F` during /// its execution. /// /// The value of the task-local must be `'static` and will be dropped on the /// com...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/task_local.rs
281
340
tokio-rs/tokio:tokio/src/task/task_local.rs:9
fn drop(this: Pin<&mut Self>) { let this = this.project(); if mem::needs_drop::<F>() && this.future.is_some() { // Drop the future while the task-local is set, if possible. Otherwise // the future is dropped normally when the `Option<F>` field drops. ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/task_local.rs
321
380
tokio-rs/tokio:tokio/src/task/task_local.rs:10
} } impl<T: 'static, F> fmt::Debug for TaskLocalFuture<T, F> where T: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// Format the Option without Some. struct TransparentOption<'a, T> { value: &'a Option<T>, } impl<'a, T: fmt::Debug> fmt::D...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/task_local.rs
361
420
tokio-rs/tokio:tokio/src/task/task_local.rs:11
impl fmt::Display for AccessError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt("task-local value not set", f) } } impl Error for AccessError {} enum ScopeInnerErr { BorrowError, AccessError, } impl ScopeInnerErr { #[track_caller] fn panic(&self) -> ! ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/task_local.rs
401
434
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, mem, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The ma...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
fb08591b43a412e6804f679fe35667906b67b324
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fb08591b43a412e6804f679fe35667906b67b324/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, mem, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The ma...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e63d0f10bf614dbd7b85d04a6e01bf8378b5194a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e63d0f10bf614dbd7b85d04a6e01bf8378b5194a/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:2
$crate::__task_local_inner!($(#[$attr])* $vis $name, $t); $crate::task_local!($($rest)*); }; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[cfg(not(tokio_no_const_thread_local))] #[macro_export] mac...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e63d0f10bf614dbd7b85d04a6e01bf8378b5194a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e63d0f10bf614dbd7b85d04a6e01bf8378b5194a/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:5
/// On completion of `sync_scope`, the task-local will be dropped. /// /// ### Panics /// /// This method panics if called inside a call to [`with`] or [`try_with`] /// on the same `LocalKey`. /// /// ### Examples /// /// ``` /// # async fn dox() { /// tokio::task_local! { ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e63d0f10bf614dbd7b85d04a6e01bf8378b5194a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e63d0f10bf614dbd7b85d04a6e01bf8378b5194a/tokio/src/task/task_local.rs
161
220
tokio-rs/tokio:tokio/src/task/task_local.rs:6
local: &'static LocalKey<T>, slot: &'a mut Option<T>, } impl<'a, T: 'static> Drop for Guard<'a, T> { fn drop(&mut self) { // This should not panic. // // We know that the RefCell was not borrowed before the call to ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e63d0f10bf614dbd7b85d04a6e01bf8378b5194a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e63d0f10bf614dbd7b85d04a6e01bf8378b5194a/tokio/src/task/task_local.rs
201
260
tokio-rs/tokio:tokio/src/task/task_local.rs:7
/// Accesses the current task-local and runs the provided closure. /// /// # Panics /// /// This function will panic if the task local doesn't have a value set. #[track_caller] pub fn with<F, R>(&'static self, f: F) -> R where F: FnOnce(&T) -> R, { match self.try_with(f) ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e63d0f10bf614dbd7b85d04a6e01bf8378b5194a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e63d0f10bf614dbd7b85d04a6e01bf8378b5194a/tokio/src/task/task_local.rs
241
300
tokio-rs/tokio:tokio/src/task/task_local.rs:8
} } impl<T: Copy + 'static> LocalKey<T> { /// Returns a copy of the task-local value /// if the task-local value implements `Copy`. /// /// # Panics /// /// This function will panic if the task local doesn't have a value set. #[track_caller] pub fn get(&'static self) -> T { self...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e63d0f10bf614dbd7b85d04a6e01bf8378b5194a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e63d0f10bf614dbd7b85d04a6e01bf8378b5194a/tokio/src/task/task_local.rs
281
340
tokio-rs/tokio:tokio/src/task/task_local.rs:9
/// println!("task local value: {}", NUMBER.get()); /// }).await; /// # } /// ``` pub struct TaskLocalFuture<T, F> where T: 'static, { local: &'static LocalKey<T>, slot: Option<T>, #[pin] future: Option<F>, #[pin] _pinned: PhantomPinned...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e63d0f10bf614dbd7b85d04a6e01bf8378b5194a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e63d0f10bf614dbd7b85d04a6e01bf8378b5194a/tokio/src/task/task_local.rs
321
380
tokio-rs/tokio:tokio/src/task/task_local.rs:10
.local .scope_inner(this.slot, || match future_opt.as_mut().as_pin_mut() { Some(fut) => { let res = fut.poll(cx); if res.is_ready() { future_opt.set(None); } Some(res) } ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e63d0f10bf614dbd7b85d04a6e01bf8378b5194a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e63d0f10bf614dbd7b85d04a6e01bf8378b5194a/tokio/src/task/task_local.rs
361
420
tokio-rs/tokio:tokio/src/task/task_local.rs:11
.field("value", &TransparentOption { value: &self.slot }) .finish() } } /// An error returned by [`LocalKey::try_with`](method@LocalKey::try_with). #[derive(Clone, Copy, Eq, PartialEq)] pub struct AccessError { _private: (), } impl fmt::Debug for AccessError { fn fmt(&self, f: &mut fmt::Format...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e63d0f10bf614dbd7b85d04a6e01bf8378b5194a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e63d0f10bf614dbd7b85d04a6e01bf8378b5194a/tokio/src/task/task_local.rs
401
451
tokio-rs/tokio:tokio/src/task/task_local.rs:12
impl From<std::cell::BorrowMutError> for ScopeInnerErr { fn from(_: std::cell::BorrowMutError) -> Self { Self::BorrowError } } impl From<std::thread::AccessError> for ScopeInnerErr { fn from(_: std::thread::AccessError) -> Self { Self::AccessError } }
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e63d0f10bf614dbd7b85d04a6e01bf8378b5194a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e63d0f10bf614dbd7b85d04a6e01bf8378b5194a/tokio/src/task/task_local.rs
441
451
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, mem, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro wraps any number of static decl...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
1fd7f8246863e8396e0a98b5bb04de32d36b7fa3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1fd7f8246863e8396e0a98b5bb04de32d36b7fa3/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:2
$crate::task_local!($($rest)*); }; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[cfg(not(tokio_no_const_thread_local))] #[macro_export] macro_rules! __task_local_inner { ($(#[$attr:meta])* $vis:vis $na...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
1fd7f8246863e8396e0a98b5bb04de32d36b7fa3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1fd7f8246863e8396e0a98b5bb04de32d36b7fa3/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:5
/// /// ### Panics /// /// This method panics if called inside a call to [`with`] or [`try_with`] /// on the same `LocalKey`. /// /// ### Examples /// /// ``` /// # async fn dox() { /// tokio::task_local! { /// static NUMBER: u32; /// } /// /// NUMBER.sync_sco...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
1fd7f8246863e8396e0a98b5bb04de32d36b7fa3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1fd7f8246863e8396e0a98b5bb04de32d36b7fa3/tokio/src/task/task_local.rs
161
220
tokio-rs/tokio:tokio/src/task/task_local.rs:6
slot: &'a mut Option<T>, } impl<'a, T: 'static> Drop for Guard<'a, T> { fn drop(&mut self) { // This should not panic. // // We know that the RefCell was not borrowed before the call to // `scope_inner`, so the only way for thi...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
1fd7f8246863e8396e0a98b5bb04de32d36b7fa3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1fd7f8246863e8396e0a98b5bb04de32d36b7fa3/tokio/src/task/task_local.rs
201
260
tokio-rs/tokio:tokio/src/task/task_local.rs:7
/// /// # Panics /// /// This function will panic if the task local doesn't have a value set. #[track_caller] pub fn with<F, R>(&'static self, f: F) -> R where F: FnOnce(&T) -> R, { match self.try_with(f) { Ok(res) => res, Err(_) => panic!("cannot acce...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
1fd7f8246863e8396e0a98b5bb04de32d36b7fa3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1fd7f8246863e8396e0a98b5bb04de32d36b7fa3/tokio/src/task/task_local.rs
241
300
tokio-rs/tokio:tokio/src/task/task_local.rs:8
} impl<T: Copy + 'static> LocalKey<T> { /// Returns a copy of the task-local value /// if the task-local value implements `Copy`. /// /// # Panics /// /// This function will panic if the task local doesn't have a value set. #[track_caller] pub fn get(&'static self) -> T { self.w...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
1fd7f8246863e8396e0a98b5bb04de32d36b7fa3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1fd7f8246863e8396e0a98b5bb04de32d36b7fa3/tokio/src/task/task_local.rs
281
340
tokio-rs/tokio:tokio/src/task/task_local.rs:9
/// # } /// ``` // Doesn't use pin_project due to custom Drop. pub struct TaskLocalFuture<T, F> where T: 'static, { local: &'static LocalKey<T>, slot: Option<T>, future: Option<F>, _pinned: PhantomPinned, } impl<T: 'static, F: Future> Future for TaskLocalFuture<T, F> { type Output = F::Output; ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
1fd7f8246863e8396e0a98b5bb04de32d36b7fa3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1fd7f8246863e8396e0a98b5bb04de32d36b7fa3/tokio/src/task/task_local.rs
321
380
tokio-rs/tokio:tokio/src/task/task_local.rs:10
} } } impl<T: 'static, F> Drop for TaskLocalFuture<T, F> { fn drop(&mut self) { if mem::needs_drop::<F>() && self.future.is_some() { // Drop the future while the task-local is set, if possible. Otherwise // the future is dropped normally when the `Option<F>` field drops. ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
1fd7f8246863e8396e0a98b5bb04de32d36b7fa3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1fd7f8246863e8396e0a98b5bb04de32d36b7fa3/tokio/src/task/task_local.rs
361
420
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, mem, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro wraps any number of static decl...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
b673eae3423516b436ed61a9b87d5428efb10fbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b673eae3423516b436ed61a9b87d5428efb10fbf/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:2
$crate::task_local!($($rest)*); }; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[cfg(not(tokio_no_const_thread_local))] #[macro_export] macro_rules! __task_local_inner { ($(#[$attr:meta])* $vis:vis $na...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
b673eae3423516b436ed61a9b87d5428efb10fbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b673eae3423516b436ed61a9b87d5428efb10fbf/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:5
/// /// This method panics if called inside a call to [`with`] or [`try_with`] /// on the same `LocalKey`. /// /// ### Examples /// /// ``` /// # async fn dox() { /// tokio::task_local! { /// static NUMBER: u32; /// } /// /// NUMBER.sync_scope(1, || { /// prin...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
b673eae3423516b436ed61a9b87d5428efb10fbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b673eae3423516b436ed61a9b87d5428efb10fbf/tokio/src/task/task_local.rs
161
220
tokio-rs/tokio:tokio/src/task/task_local.rs:6
impl<'a, T: 'static> Drop for Guard<'a, T> { fn drop(&mut self) { // This should not panic. // // We know that the RefCell was not borrowed before the call to // `scope_inner`, so the only way for this to panic is if the // clos...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
b673eae3423516b436ed61a9b87d5428efb10fbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b673eae3423516b436ed61a9b87d5428efb10fbf/tokio/src/task/task_local.rs
201
260
tokio-rs/tokio:tokio/src/task/task_local.rs:7
/// /// This function will panic if the task local doesn't have a value set. #[track_caller] pub fn with<F, R>(&'static self, f: F) -> R where F: FnOnce(&T) -> R, { match self.try_with(f) { Ok(res) => res, Err(_) => panic!("cannot access a task-local storage v...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
b673eae3423516b436ed61a9b87d5428efb10fbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b673eae3423516b436ed61a9b87d5428efb10fbf/tokio/src/task/task_local.rs
241
300
tokio-rs/tokio:tokio/src/task/task_local.rs:8
impl<T: Copy + 'static> LocalKey<T> { /// Returns a copy of the task-local value /// if the task-local value implements `Copy`. /// /// # Panics /// /// This function will panic if the task local doesn't have a value set. pub fn get(&'static self) -> T { self.with(|v| *v) } } im...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
b673eae3423516b436ed61a9b87d5428efb10fbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b673eae3423516b436ed61a9b87d5428efb10fbf/tokio/src/task/task_local.rs
281
340
tokio-rs/tokio:tokio/src/task/task_local.rs:9
pub struct TaskLocalFuture<T, F> where T: 'static, { local: &'static LocalKey<T>, slot: Option<T>, future: Option<F>, _pinned: PhantomPinned, } impl<T: 'static, F: Future> Future for TaskLocalFuture<T, F> { type Output = F::Output; #[track_caller] fn poll(self: Pin<&mut Self>, cx: &mut...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
b673eae3423516b436ed61a9b87d5428efb10fbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b673eae3423516b436ed61a9b87d5428efb10fbf/tokio/src/task/task_local.rs
321
380
tokio-rs/tokio:tokio/src/task/task_local.rs:10
impl<T: 'static, F> Drop for TaskLocalFuture<T, F> { fn drop(&mut self) { if mem::needs_drop::<F>() && self.future.is_some() { // Drop the future while the task-local is set, if possible. Otherwise // the future is dropped normally when the `Option<F>` field drops. let fu...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
b673eae3423516b436ed61a9b87d5428efb10fbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b673eae3423516b436ed61a9b87d5428efb10fbf/tokio/src/task/task_local.rs
361
420
tokio-rs/tokio:tokio/src/task/task_local.rs:11
#[derive(Clone, Copy, Eq, PartialEq)] pub struct AccessError { _private: (), } impl fmt::Debug for AccessError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("AccessError").finish() } } impl fmt::Display for AccessError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
b673eae3423516b436ed61a9b87d5428efb10fbf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b673eae3423516b436ed61a9b87d5428efb10fbf/tokio/src/task/task_local.rs
401
444
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, mem, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro wraps any number of static decl...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
5288e1e144d33ace0070325b16029523b1db0ffe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5288e1e144d33ace0070325b16029523b1db0ffe/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:2
$crate::task_local!($($rest)*); }; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[cfg(tokio_const_thread_local)] #[macro_export] macro_rules! __task_local_inner { ($(#[$attr:meta])* $vis:vis $name:ident...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
5288e1e144d33ace0070325b16029523b1db0ffe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5288e1e144d33ace0070325b16029523b1db0ffe/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:7
/// /// # Panics /// /// This function will panic if the task local doesn't have a value set. #[track_caller] pub fn with<F, R>(&'static self, f: F) -> R where F: FnOnce(&T) -> R, { match self.try_with(f) { Ok(res) => res, Err(_) => panic!("cannot acce...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
922fc91408d68f0a6e66e14c99cb47a16e8653af
github
async-runtime
https://github.com/tokio-rs/tokio/blob/922fc91408d68f0a6e66e14c99cb47a16e8653af/tokio/src/task/task_local.rs
241
300
tokio-rs/tokio:tokio/src/task/task_local.rs:8
} impl<T: Copy + 'static> LocalKey<T> { /// Returns a copy of the task-local value /// if the task-local value implements `Copy`. /// /// # Panics /// /// This function will panic if the task local doesn't have a value set. pub fn get(&'static self) -> T { self.with(|v| *v) } } ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
922fc91408d68f0a6e66e14c99cb47a16e8653af
github
async-runtime
https://github.com/tokio-rs/tokio/blob/922fc91408d68f0a6e66e14c99cb47a16e8653af/tokio/src/task/task_local.rs
281
340
tokio-rs/tokio:tokio/src/task/task_local.rs:9
/// ``` // Doesn't use pin_project due to custom Drop. pub struct TaskLocalFuture<T, F> where T: 'static, { local: &'static LocalKey<T>, slot: Option<T>, future: Option<F>, _pinned: PhantomPinned, } impl<T: 'static, F: Future> Future for TaskLocalFuture<T, F> { type Output = F::Output; #[t...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
922fc91408d68f0a6e66e14c99cb47a16e8653af
github
async-runtime
https://github.com/tokio-rs/tokio/blob/922fc91408d68f0a6e66e14c99cb47a16e8653af/tokio/src/task/task_local.rs
321
380
tokio-rs/tokio:tokio/src/task/task_local.rs:10
} } impl<T: 'static, F> Drop for TaskLocalFuture<T, F> { fn drop(&mut self) { if mem::needs_drop::<F>() && self.future.is_some() { // Drop the future while the task-local is set, if possible. Otherwise // the future is dropped normally when the `Option<F>` field drops. l...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
922fc91408d68f0a6e66e14c99cb47a16e8653af
github
async-runtime
https://github.com/tokio-rs/tokio/blob/922fc91408d68f0a6e66e14c99cb47a16e8653af/tokio/src/task/task_local.rs
361
420
tokio-rs/tokio:tokio/src/task/task_local.rs:11
/// An error returned by [`LocalKey::try_with`](method@LocalKey::try_with). #[derive(Clone, Copy, Eq, PartialEq)] pub struct AccessError { _private: (), } impl fmt::Debug for AccessError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("AccessError").finish() } } impl fm...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
922fc91408d68f0a6e66e14c99cb47a16e8653af
github
async-runtime
https://github.com/tokio-rs/tokio/blob/922fc91408d68f0a6e66e14c99cb47a16e8653af/tokio/src/task/task_local.rs
401
446
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, mem, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro wraps any number of static decl...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e6020c0fed28128fce85d69352b540ddc1bbaf69
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e6020c0fed28128fce85d69352b540ddc1bbaf69/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:2
$crate::task_local!($($rest)*); }; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[cfg(tokio_const_thread_local)] #[macro_export] macro_rules! __task_local_inner { ($(#[$attr:meta])* $vis:vis $name:ident...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e6020c0fed28128fce85d69352b540ddc1bbaf69
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e6020c0fed28128fce85d69352b540ddc1bbaf69/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro w...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
7f92bce39f7046e204381127936e2014094f9638
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f92bce39f7046e204381127936e2014094f9638/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:2
$crate::__task_local_inner!($(#[$attr])* $vis $name, $t); $crate::task_local!($($rest)*); }; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[cfg(tokio_const_thread_local)] #[macro_export] macro_rules...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
7f92bce39f7046e204381127936e2014094f9638
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f92bce39f7046e204381127936e2014094f9638/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:4
/// /// ### Examples /// /// ``` /// # async fn dox() { /// tokio::task_local! { /// static NUMBER: u32; /// } /// /// NUMBER.scope(1, async move { /// println!("task local value: {}", NUMBER.get()); /// }).await; /// # } /// ``` pub fn scope<F>(&'static s...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
7f92bce39f7046e204381127936e2014094f9638
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f92bce39f7046e204381127936e2014094f9638/tokio/src/task/task_local.rs
121
180
tokio-rs/tokio:tokio/src/task/task_local.rs:5
/// }); /// # } /// ``` pub fn sync_scope<F, R>(&'static self, value: T, f: F) -> R where F: FnOnce() -> R, { let scope = TaskLocalFuture { local: self, slot: Some(value), future: (), _pinned: PhantomPinned, }; crate::pi...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
7f92bce39f7046e204381127936e2014094f9638
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f92bce39f7046e204381127936e2014094f9638/tokio/src/task/task_local.rs
161
220
tokio-rs/tokio:tokio/src/task/task_local.rs:6
F: FnOnce(&T) -> R, { self.inner.with(|v| { if let Some(val) = v.borrow().as_ref() { Ok(f(val)) } else { Err(AccessError { _private: () }) } }) } } impl<T: Copy + 'static> LocalKey<T> { /// Returns a copy of the task-local ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
7f92bce39f7046e204381127936e2014094f9638
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f92bce39f7046e204381127936e2014094f9638/tokio/src/task/task_local.rs
201
260
tokio-rs/tokio:tokio/src/task/task_local.rs:7
/// static NUMBER: u32; /// } /// /// NUMBER.scope(1, async move { /// println!("task local value: {}", NUMBER.get()); /// }).await; /// # } /// ``` pub struct TaskLocalFuture<T, F> where T: 'static { local: &'static LocalKey<T>, slot: Option<T>, ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
7f92bce39f7046e204381127936e2014094f9638
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f92bce39f7046e204381127936e2014094f9638/tokio/src/task/task_local.rs
241
300
tokio-rs/tokio:tokio/src/task/task_local.rs:8
let _guard = Guard { prev, slot: project.slot, local: *project.local, }; f(project.future) } } impl<T: 'static, F: Future> Future for TaskLocalFuture<T, F> { type Output = F::Output; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Outp...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
7f92bce39f7046e204381127936e2014094f9638
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7f92bce39f7046e204381127936e2014094f9638/tokio/src/task/task_local.rs
281
318
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro w...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
fe770dc509b19c5159ece7e38f353c5e30df3d6c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fe770dc509b19c5159ece7e38f353c5e30df3d6c/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:2
$crate::__task_local_inner!($(#[$attr])* $vis $name, $t); $crate::task_local!($($rest)*); }; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[macro_export] macro_rules! __task_local_inner { ($(#[$...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
fe770dc509b19c5159ece7e38f353c5e30df3d6c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fe770dc509b19c5159ece7e38f353c5e30df3d6c/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:3
/// NUMBER.scope(1, async move { /// assert_eq!(NUMBER.get(), 1); /// }).await; /// /// NUMBER.scope(2, async move { /// assert_eq!(NUMBER.get(), 2); /// /// NUMBER.scope(3, async move { /// assert_eq!(NUMBER.get(), 3); /// }).await; /// }).await; /// # } /// ``` /// [`std::thread::LocalKey`]: s...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
fe770dc509b19c5159ece7e38f353c5e30df3d6c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fe770dc509b19c5159ece7e38f353c5e30df3d6c/tokio/src/task/task_local.rs
81
140
tokio-rs/tokio:tokio/src/task/task_local.rs:4
F: Future, { TaskLocalFuture { local: self, slot: Some(value), future: f, _pinned: PhantomPinned, } } /// Sets a value `T` as the task-local value for the closure `F`. /// /// On completion of `scope`, the task-local will be dropped. ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
fe770dc509b19c5159ece7e38f353c5e30df3d6c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fe770dc509b19c5159ece7e38f353c5e30df3d6c/tokio/src/task/task_local.rs
121
180
tokio-rs/tokio:tokio/src/task/task_local.rs:5
/// Accesses the current task-local and runs the provided closure. /// /// # Panics /// /// This function will panic if not called within the context /// of a future containing a task-local with the corresponding key. pub fn with<F, R>(&'static self, f: F) -> R where F: FnOnce(&T) ->...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
fe770dc509b19c5159ece7e38f353c5e30df3d6c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fe770dc509b19c5159ece7e38f353c5e30df3d6c/tokio/src/task/task_local.rs
161
220
tokio-rs/tokio:tokio/src/task/task_local.rs:6
self.with(|v| *v) } } impl<T: 'static> fmt::Debug for LocalKey<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("LocalKey { .. }") } } pin_project! { /// A future that sets a value `T` of a task local for the future `F` during /// its execution. /// /// The val...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
fe770dc509b19c5159ece7e38f353c5e30df3d6c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fe770dc509b19c5159ece7e38f353c5e30df3d6c/tokio/src/task/task_local.rs
201
260
tokio-rs/tokio:tokio/src/task/task_local.rs:7
#[pin] _pinned: PhantomPinned, } } impl<T: 'static, F> TaskLocalFuture<T, F> { fn with_task<F2: FnOnce(Pin<&mut F>) -> R, R>(self: Pin<&mut Self>, f: F2) -> R { struct Guard<'a, T: 'static> { local: &'static LocalKey<T>, slot: &'a mut Option<T>, prev: Option<...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
fe770dc509b19c5159ece7e38f353c5e30df3d6c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fe770dc509b19c5159ece7e38f353c5e30df3d6c/tokio/src/task/task_local.rs
241
300
tokio-rs/tokio:tokio/src/task/task_local.rs:8
} } /// An error returned by [`LocalKey::try_with`](method@LocalKey::try_with). #[derive(Clone, Copy, Eq, PartialEq)] pub struct AccessError { _private: (), } impl fmt::Debug for AccessError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("AccessError").finish() } } im...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
fe770dc509b19c5159ece7e38f353c5e30df3d6c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fe770dc509b19c5159ece7e38f353c5e30df3d6c/tokio/src/task/task_local.rs
281
302
tokio-rs/tokio:tokio/src/task/task_local.rs:7
#[pin] _pinned: PhantomPinned, } } impl<T: 'static, F> TaskLocalFuture<T, F> { fn with_task<F2: FnOnce(Pin<&mut F>) -> R, R>(self: Pin<&mut Self>, f: F2) -> R { struct Guard<'a, T: 'static> { local: &'static LocalKey<T>, slot: &'a mut Option<T>, prev: Option<...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/task/task_local.rs
241
300
tokio-rs/tokio:tokio/src/task/task_local.rs:3
/// NUMBER.scope(1, async move { /// assert_eq!(NUMBER.get(), 1); /// }).await; /// /// NUMBER.scope(2, async move { /// assert_eq!(NUMBER.get(), 2); /// /// NUMBER.scope(3, async move { /// assert_eq!(NUMBER.get(), 3); /// }).await; /// }).await; /// # } /// ``` /// [`std::thread::LocalKey`]: s...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
7a11cfd77a00d383f090a876768f34c66d5dc538
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a11cfd77a00d383f090a876768f34c66d5dc538/tokio/src/task/task_local.rs
81
140
tokio-rs/tokio:tokio/src/task/task_local.rs:4
F: Future, { TaskLocalFuture { local: &self, slot: Some(value), future: f, _pinned: PhantomPinned, } } /// Sets a value `T` as the task-local value for the closure `F`. /// /// On completion of `scope`, the task-local will be dropped. ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
7a11cfd77a00d383f090a876768f34c66d5dc538
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7a11cfd77a00d383f090a876768f34c66d5dc538/tokio/src/task/task_local.rs
121
180
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro wraps any number of static declar...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:2
$crate::task_local!($($rest)*); }; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[macro_export] macro_rules! __task_local_inner { ($(#[$attr:meta])* $vis:vis $name:ident, $t:ty) => { $vis static...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:3
/// assert_eq!(NUMBER.get(), 1); /// }).await; /// /// NUMBER.scope(2, async move { /// assert_eq!(NUMBER.get(), 2); /// /// NUMBER.scope(3, async move { /// assert_eq!(NUMBER.get(), 3); /// }).await; /// }).await; /// # } /// ``` /// [`std::thread::LocalKey`]: struct@std::thread::LocalKey #[cfg...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe/tokio/src/task/task_local.rs
81
140
tokio-rs/tokio:tokio/src/task/task_local.rs:4
{ TaskLocalFuture { local: &self, slot: Some(value), future: f, } } /// Sets a value `T` as the task-local value for the closure `F`. /// /// On completion of `scope`, the task-local will be dropped. /// /// ### Examples /// /// ``` ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe/tokio/src/task/task_local.rs
121
180
tokio-rs/tokio:tokio/src/task/task_local.rs:5
/// /// This function will panic if not called within the context /// of a future containing a task-local with the corresponding key. pub fn with<F, R>(&'static self, f: F) -> R where F: FnOnce(&T) -> R, { self.try_with(f).expect( "cannot access a Task Local Storage value...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe/tokio/src/task/task_local.rs
161
220
tokio-rs/tokio:tokio/src/task/task_local.rs:6
impl<T: 'static> fmt::Debug for LocalKey<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("LocalKey { .. }") } } pin_project! { /// A future that sets a value `T` of a task local for the future `F` during /// its execution. /// /// The value of the task-local must b...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe/tokio/src/task/task_local.rs
201
260
tokio-rs/tokio:tokio/src/task/task_local.rs:7
fn with_task<F2: FnOnce(Pin<&mut F>) -> R, R>(self: Pin<&mut Self>, f: F2) -> R { struct Guard<'a, T: 'static> { local: &'static LocalKey<T>, slot: &'a mut Option<T>, prev: Option<T>, } impl<T> Drop for Guard<'_, T> { fn drop(&mut self) { ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe/tokio/src/task/task_local.rs
241
296
tokio-rs/tokio:tokio/src/task/task_local.rs:8
_private: (), } impl fmt::Debug for AccessError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("AccessError").finish() } } impl fmt::Display for AccessError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt("task-local value not set...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6fbb9aeb1f8f52055d0fc506f8ac2ffac700bfe/tokio/src/task/task_local.rs
281
296
tokio-rs/tokio:tokio/src/task/task_local.rs:3
/// assert_eq!(NUMBER.get(), 1); /// }).await; /// /// NUMBER.scope(2, async move { /// assert_eq!(NUMBER.get(), 2); /// /// NUMBER.scope(3, async move { /// assert_eq!(NUMBER.get(), 3); /// }).await; /// }).await; /// # } /// ``` /// [`std::thread::LocalKey`]: struct@std::thread::LocalKey #[cfg...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/task/task_local.rs
81
140
tokio-rs/tokio:tokio/src/task/task_local.rs:4
{ TaskLocalFuture { local: &self, slot: Some(value), future: f, } .await } /// Sets a value `T` as the task-local value for the closure `F`. /// /// On completion of `scope`, the task-local will be dropped. /// /// ### Examples ///...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/task/task_local.rs
121
180
tokio-rs/tokio:tokio/src/task/task_local.rs:5
/// # Panics /// /// This function will panic if not called within the context /// of a future containing a task-local with the corresponding key. pub fn with<F, R>(&'static self, f: F) -> R where F: FnOnce(&T) -> R, { self.try_with(f).expect( "cannot access a Task Lo...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/task/task_local.rs
161
220
tokio-rs/tokio:tokio/src/task/task_local.rs:6
impl<T: 'static> fmt::Debug for LocalKey<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("LocalKey { .. }") } } pin_project! { struct TaskLocalFuture<T: StaticLifetime, F> { local: &'static LocalKey<T>, slot: Option<T>, #[pin] future: F, } }...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/task/task_local.rs
201
260
tokio-rs/tokio:tokio/src/task/task_local.rs:7
}; f(project.future) } } impl<T: 'static, F: Future> Future for TaskLocalFuture<T, F> { type Output = F::Output; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { self.with_task(|f| f.poll(cx)) } } // Required to make `pin_project` happy. trait StaticLifetim...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/task/task_local.rs
241
277
tokio-rs/tokio:tokio/src/task/task_local.rs:4
{ TaskLocalFuture { local: &self, slot: Some(value), future: f, } .await } /// Sets a value `T` as the task-local value for the closure `F`. /// /// On completion of `scope`, the task-local will be dropped. /// /// ### Examples ///...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c659e4a757b5a2a63378ead33917f4e072dba5dc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c659e4a757b5a2a63378ead33917f4e072dba5dc/tokio/src/task/task_local.rs
121
180