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/local.rs:14
) } /// Spawns a `!Send` task onto the local task set. /// /// This task is guaranteed to be run on the current thread. /// /// Unlike the free function [`spawn_local`], this method may be used to /// spawn local tasks when the `LocalSet` is _not_ running. The provided /// future will s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:17
#[track_caller] #[cfg(feature = "rt")] #[cfg_attr(docsrs, doc(cfg(feature = "rt")))] pub fn block_on<F>(&self, rt: &crate::runtime::Runtime, future: F) -> F::Output where F: Future, { rt.block_on(self.run_until(future)) } /// Runs a future to completion on the local set, ret...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
/// [`spawn_local`]: fn@spawn_local /// [awaiting the local set]: #awaiting-a-localset pub async fn run_until<F>(&self, future: F) -> F::Output where F: Future, { let run_until = RunUntil { future, local_set: self, }; run_until.await } #[t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
self.context.shared.waker.wake(); handle } /// Ticks the scheduler, returning whether the local future needs to be /// notified again. fn tick(&self) -> bool { for _ in 0..MAX_TASKS_PER_TICK { // Make sure we didn't hit an unhandled panic assert!(!self.context.un...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:20
.as_mut() .and_then(|queue| queue.pop_front()) .or_else(|| self.pop_local()) } else { self.pop_local().or_else(|| { self.context .shared .queue .lock() .as_mut() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
fn with_if_possible<T>(&self, f: impl FnOnce() -> T) -> T { let mut f = Some(f); let res = CURRENT.try_with(|local_data| { let _guard = local_data.enter(self.context.clone()); (f.take().unwrap())() }); match res { Ok(res) => res, Err(_acc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:23
.unhandled_panic = behavior; self } /// Returns the [`Id`] of the current `LocalSet` runtime. /// /// # Examples /// /// ```rust /// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// let local_set = ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
let _no_blocking = crate::runtime::context::disallow_block_in_place(); // Register the waker before starting to work self.context.shared.waker.register_by_ref(cx.waker()); if self.with(|| self.tick()) { // If `tick` returns true, we need to notify the local future again: ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
self.context.shared.local_state.close_and_shutdown_all(); } // We already called shutdown on all tasks above, so there is no // need to call shutdown. // Safety: note that this *intentionally* bypasses the unsafe // `Shared::local_queue()` method. This is in...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
impl Context { #[track_caller] fn spawn<F>(&self, future: F, meta: SpawnMeta<'_>) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { let id = crate::runtime::task::Id::next(); let future = crate::util::trace::task(future, "local", meta, id.as_u64())...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
.context .shared .waker .register_by_ref(cx.waker()); let _no_blocking = crate::runtime::context::disallow_block_in_place(); let f = me.future; if let Poll::Ready(output) = f.poll(cx) { return Poll::Ready(output); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
unsafe { // Safety: we just checked that the thread ID matches // the localset's owner, so this is safe. self.local_state.task_push_back(task); } // We still have to wake the `LocalSet`, because it isn't ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
unsafe { self.local_state.task_remove(task) } } fn schedule(&self, task: task::Notified<Self>) { Shared::schedule(self, task); } // localset does not currently support task hooks fn hooks(&self) -> TaskHarnessScheduleHooks { TaskHarnessScheduleHooks { task_terminate_cal...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
impl LocalState { unsafe fn task_pop_front(&self) -> Option<task::Notified<Arc<Shared>>> { // The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_thread(); self.local_queue.with_mut(|ptr| (*ptr).pop_front()) } unsafe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
} unsafe fn assert_owner( &self, task: task::Notified<Arc<Shared>>, ) -> task::LocalNotified<Arc<Shared>> { // The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_thread(); self.owned.assert_owner(task) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
1,201
1,260
tokio-rs/tokio:tokio/src/task/local.rs:32
unsafe impl Send for LocalState {} #[cfg(all(test, not(loom)))] mod tests { use super::*; // Does a `LocalSet` running on a current-thread runtime...basically work? // // This duplicates a test in `tests/task_local_set.rs`, but because this is // a lib test, it will run under Miri, so this is nece...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
1,241
1,300
tokio-rs/tokio:tokio/src/task/local.rs:33
rt.block_on(async { let local = LocalSet::new(); let notify = Arc::new(Notify::new()); let task = local.spawn_local({ let notify = notify.clone(); async move { notify.notified().await; } }); l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
1,281
1,311
tokio-rs/tokio:tokio/src/task/local.rs:10
/// }).await.unwrap(); /// }).await; /// } /// ``` /// /// [`LocalSet`]: struct@crate::task::LocalSet /// [`LocalRuntime`]: struct@crate::runtime::LocalRuntime /// [`tokio::spawn`]: fn@crate::task::spawn #[track_caller] pub fn spawn_local<F>(future: F) -> JoinHandle<F::Ou...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
#[cfg(all( tokio_unstable, tokio_taskdump, feature = "rt", target_os = "linux", any( target_arch = "aarch64", target_arch = "x86", target_arch = "x8...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:1
//! Runs `!Send` futures on the current thread. use crate::loom::cell::UnsafeCell; use crate::loom::sync::{Arc, Mutex}; #[cfg(tokio_unstable)] use crate::runtime; use crate::runtime::task::{self, JoinHandle, LocalOwnedTasks, Task, TaskHarnessScheduleHooks}; use crate::runtime::{context, ThreadId, BOX_FUTURE_THRESHOLD};...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
1
60
tokio-rs/tokio:tokio/src/task/local.rs:6
/// } /// } /// /// #[tokio::main] /// async fn main() { /// let spawner = LocalSpawner::new(); /// /// let (send, response) = oneshot::channel(); /// spawner.spawn(Task::AddOne(10, send)); /// let eleven = response.await.unwrap(); /// assert_eq!(eleven, 1...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:7
/// `LocalSet` state shared between threads. struct Shared { /// # Safety /// /// This field must *only* be accessed from the thread that owns the /// `LocalSet` (i.e., `Thread::current().id() == owner`). local_state: LocalState, /// Remote run queue sender. queue: Mutex<Option<VecDeque<tas...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
} tokio_thread_local!(static CURRENT: LocalData = const { LocalData { ctx: RcCell::new(), wake_on_schedule: Cell::new(false), } }); struct LocalData { ctx: RcCell<Context>, wake_on_schedule: Cell<bool>, } impl LocalData { /// Should be called except when we call `LocalSet::enter`. /// Especia...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
} } cfg_rt! { /// Spawns a `!Send` future on the current [`LocalSet`] or [`LocalRuntime`]. /// /// The spawned future will run on the same thread that called `spawn_local`. /// /// The provided future will start running in the background immediately /// when `spawn_local` is called, even if you...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
/// } /// ``` /// /// [`LocalSet`]: struct@crate::task::LocalSet /// [`LocalRuntime`]: struct@crate::runtime::LocalRuntime /// [`tokio::spawn`]: fn@crate::task::spawn #[track_caller] pub fn spawn_local<F>(future: F) -> JoinHandle<F::Output> where F: Future + 'static, F::O...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
tokio_taskdump, feature = "rt", target_os = "linux", any( target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64" ) ))] let...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
/// How often it check the remote queue first. const REMOTE_FIRST_INTERVAL: u8 = 31; /// Context guard for `LocalSet` pub struct LocalEnterGuard { ctx: Option<Rc<Context>>, /// Distinguishes whether the context was entered or being polled. /// When we enter it, the value `wake_on_schedule` is set. In this...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
context: Rc::new(Context { shared: Arc::new(Shared { local_state: LocalState { owner, owned: LocalOwnedTasks::new(), local_queue: UnsafeCell::new(VecDeque::with_capacity(INITIAL_CAPACITY)), },...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:17
#[cfg_attr(docsrs, doc(cfg(feature = "rt")))] pub fn block_on<F>(&self, rt: &crate::runtime::Runtime, future: F) -> F::Output where F: Future, { rt.block_on(self.run_until(future)) } /// Runs a future to completion on the local set, returning its output. /// /// This returns...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
pub async fn run_until<F>(&self, future: F) -> F::Output where F: Future, { let run_until = RunUntil { future, local_set: self, }; run_until.await } #[track_caller] pub(in crate::task) fn spawn_named<F>( &self, future: F, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
} /// Ticks the scheduler, returning whether the local future needs to be /// notified again. fn tick(&self) -> bool { for _ in 0..MAX_TASKS_PER_TICK { // Make sure we didn't hit an unhandled panic assert!(!self.context.unhandled_panic.get(), "a spawned task panicked and the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:20
.or_else(|| self.pop_local()) } else { self.pop_local().or_else(|| { self.context .shared .queue .lock() .as_mut() .and_then(VecDeque::pop_front) }) }; tas...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:23
} /// Returns the [`Id`] of the current `LocalSet` runtime. /// /// # Examples /// /// ```rust /// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// let local_set = task::LocalSet::new(); /// println!("Local...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
// Register the waker before starting to work self.context.shared.waker.register_by_ref(cx.waker()); if self.with(|| self.tick()) { // If `tick` returns true, we need to notify the local future again: // there are still tasks remaining in the run queue. cx.waker().wa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
// We already called shutdown on all tasks above, so there is no // need to call shutdown. // Safety: note that this *intentionally* bypasses the unsafe // `Shared::local_queue()` method. This is in order to avoid the // debug assertion that we are on the thread that own...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
#[track_caller] fn spawn<F>(&self, future: F, meta: SpawnMeta<'_>) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { let id = crate::runtime::task::Id::next(); let future = crate::util::trace::task(future, "local", meta, id.as_u64()); // Safet...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
let _no_blocking = crate::runtime::context::disallow_block_in_place(); let f = me.future; if let Poll::Ready(output) = f.poll(cx) { return Poll::Ready(output); } if me.local_set.tick() { // If `tick` returns `true`, we need to notify the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
} // We still have to wake the `LocalSet`, because it isn't // currently being polled. self.waker.wake(); } // We are *not* on the thread that owns the `LocalSet`, so we // have to wake to the remote queue. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
Shared::schedule(self, task); } // localset does not currently support task hooks fn hooks(&self) -> TaskHarnessScheduleHooks { TaskHarnessScheduleHooks { task_terminate_callback: None, } } cfg_unstable! { fn unhandled_panic(&self) { use crate::runti...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
self.assert_called_from_owner_thread(); self.local_queue.with_mut(|ptr| (*ptr).pop_front()) } unsafe fn task_push_back(&self, task: task::Notified<Arc<Shared>>) { // The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
task: task::Notified<Arc<Shared>>, ) -> task::LocalNotified<Arc<Shared>> { // The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_thread(); self.owned.assert_owner(task) } unsafe fn close_and_shutdown_all(&self) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
1,201
1,260
tokio-rs/tokio:tokio/src/task/local.rs:32
use super::*; // Does a `LocalSet` running on a current-thread runtime...basically work? // // This duplicates a test in `tests/task_local_set.rs`, but because this is // a lib test, it will run under Miri, so this is necessary to catch stacked // borrows violations in the `LocalSet` implementation...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
1,241
1,300
tokio-rs/tokio:tokio/src/task/local.rs:33
let notify = notify.clone(); async move { notify.notified().await; } }); let mut run_until = Box::pin(local.run_until(async move { task.await.unwrap(); })); // poll the run until future once ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8259133ca018d136ebbfc7b9032eb6ca4b7a3e73
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8259133ca018d136ebbfc7b9032eb6ca4b7a3e73/tokio/src/task/local.rs
1,281
1,307
tokio-rs/tokio:tokio/src/task/local.rs:23
} /// Returns the [`Id`] of the current `LocalSet` runtime. /// /// # Examples /// /// ```rust /// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// let local_set = task::LocalSet::new(); /// println!("Local...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
605ef578df04f12a951060dc3b2fb930f6f379fe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
if self.with(|| self.tick()) { // If `tick` returns true, we need to notify the local future again: // there are still tasks remaining in the run queue. cx.waker().wake_by_ref(); Poll::Pending // Safety: called from the thread that owns `LocalSet`. Because ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
605ef578df04f12a951060dc3b2fb930f6f379fe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
// Safety: note that this *intentionally* bypasses the unsafe // `Shared::local_queue()` method. This is in order to avoid the // debug assertion that we are on the thread that owns the // `LocalSet`, because on some systems (e.g. at least some macOS // versions), attempt...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
605ef578df04f12a951060dc3b2fb930f6f379fe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
F::Output: 'static, { let id = crate::runtime::task::Id::next(); let future = crate::util::trace::task(future, "local", meta, id.as_u64()); // Safety: called from the thread that owns the `LocalSet` let (handle, notified) = { self.shared.local_state.assert_called_from_ow...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
605ef578df04f12a951060dc3b2fb930f6f379fe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:28
} // We are *not* on the thread that owns the `LocalSet`, so we // have to wake to the remote queue. _ => { // First, check whether the queue is still there (if not, the // LocalSet is dropped). Then push to it if so, and if not, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
605ef578df04f12a951060dc3b2fb930f6f379fe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
fn hooks(&self) -> TaskHarnessScheduleHooks { TaskHarnessScheduleHooks { task_terminate_callback: None, } } cfg_unstable! { fn unhandled_panic(&self) { use crate::runtime::UnhandledPanic; match self.unhandled_panic { UnhandledPanic::I...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
605ef578df04f12a951060dc3b2fb930f6f379fe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
unsafe fn task_push_back(&self, task: task::Notified<Arc<Shared>>) { // The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_thread(); self.local_queue.with_mut(|ptr| (*ptr).push_back(task)); } unsafe fn take_local_queue(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
605ef578df04f12a951060dc3b2fb930f6f379fe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
self.assert_called_from_owner_thread(); self.owned.assert_owner(task) } unsafe fn close_and_shutdown_all(&self) { // The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_thread(); self.owned.close_and_shutdown_al...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
605ef578df04f12a951060dc3b2fb930f6f379fe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/local.rs
1,201
1,260
tokio-rs/tokio:tokio/src/task/local.rs:32
// This duplicates a test in `tests/task_local_set.rs`, but because this is // a lib test, it will run under Miri, so this is necessary to catch stacked // borrows violations in the `LocalSet` implementation. #[test] fn local_current_thread_scheduler() { let f = async { LocalSet::new...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
605ef578df04f12a951060dc3b2fb930f6f379fe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/local.rs
1,241
1,300
tokio-rs/tokio:tokio/src/task/local.rs:33
}); let mut run_until = Box::pin(local.run_until(async move { task.await.unwrap(); })); // poll the run until future once std::future::poll_fn(|cx| { let _ = run_until.as_mut().poll(cx); Poll::Ready(()) }) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
605ef578df04f12a951060dc3b2fb930f6f379fe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/local.rs
1,281
1,303
tokio-rs/tokio:tokio/src/task/local.rs:18
pub async fn run_until<F>(&self, future: F) -> F::Output where F: Future, { let run_until = RunUntil { future, local_set: self, }; run_until.await } #[track_caller] pub(in crate::task) fn spawn_named<F>( &self, future: F, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
512e9decfb683d22f4a145459142542caa0894c9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
} /// Ticks the scheduler, returning whether the local future needs to be /// notified again. fn tick(&self) -> bool { for _ in 0..MAX_TASKS_PER_TICK { // Make sure we didn't hit an unhandled panic assert!(!self.context.unhandled_panic.get(), "a spawned task panicked and the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
512e9decfb683d22f4a145459142542caa0894c9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:8
} tokio_thread_local!(static CURRENT: LocalData = const { LocalData { ctx: RcCell::new(), wake_on_schedule: Cell::new(false), } }); struct LocalData { ctx: RcCell<Context>, wake_on_schedule: Cell<bool>, } impl LocalData { /// Should be called except when we call `LocalSet::enter`. /// Especia...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
} } cfg_rt! { /// Spawns a `!Send` future on the current [`LocalSet`]. /// /// The spawned future will run on the same thread that called `spawn_local`. /// /// The provided future will start running in the background immediately /// when `spawn_local` is called, even if you don't await the ret...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
/// } /// ``` /// /// [`LocalSet`]: struct@crate::task::LocalSet /// [`tokio::spawn`]: fn@crate::task::spawn #[track_caller] pub fn spawn_local<F>(future: F) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { let fut_size = std::mem::size_of...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
/// Context guard for `LocalSet` pub struct LocalEnterGuard { ctx: Option<Rc<Context>>, /// Distinguishes whether the context was entered or being polled. /// When we enter it, the value `wake_on_schedule` is set. In this case /// `spawn_local` refers the context, whereas it is not being polled now. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
local_state: LocalState { owner, owned: LocalOwnedTasks::new(), local_queue: UnsafeCell::new(VecDeque::with_capacity(INITIAL_CAPACITY)), }, queue: Mutex::new(Some(VecDeque::with_capacity(INITIAL_CAPACITY))), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:16
where F: Future, { rt.block_on(self.run_until(future)) } /// Runs a future to completion on the local set, returning its output. /// /// This returns a future that runs the given future with a local set, /// allowing it to call [`spawn_local`] to spawn additional `!Send` futures...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
F: Future, { let run_until = RunUntil { future, local_set: self, }; run_until.await } #[track_caller] pub(in crate::task) fn spawn_named<F>( &self, future: F, meta: SpawnMeta<'_>, ) -> JoinHandle<F::Output> where F:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
/// Ticks the scheduler, returning whether the local future needs to be /// notified again. fn tick(&self) -> bool { for _ in 0..MAX_TASKS_PER_TICK { // Make sure we didn't hit an unhandled panic assert!(!self.context.unhandled_panic.get(), "a spawned task panicked and the LocalS...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
self.pop_local().or_else(|| { self.context .shared .queue .lock() .as_mut() .and_then(VecDeque::pop_front) }) }; task.map(|task| unsafe { // Safety: because the `L...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:22
/// Returns the [`Id`] of the current `LocalSet` runtime. /// /// # Examples /// /// ```rust /// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// let local_set = task::LocalSet::new(); /// println!("Local set id: {}...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
841
900
tokio-rs/tokio:tokio/src/task/local.rs:23
// If `tick` returns true, we need to notify the local future again: // there are still tasks remaining in the run queue. cx.waker().wake_by_ref(); Poll::Pending // Safety: called from the thread that owns `LocalSet`. Because // `LocalSet` is `!Send`, this is safe. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
// debug assertion that we are on the thread that owns the // `LocalSet`, because on some systems (e.g. at least some macOS // versions), attempting to get the current thread ID can panic due // to the thread's local data that stores the thread ID being // dropped *before...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
let id = crate::runtime::task::Id::next(); let future = crate::util::trace::task(future, "local", meta, id.as_u64()); // Safety: called from the thread that owns the `LocalSet` let (handle, notified) = { self.shared.local_state.assert_called_from_owner_thread(); self.sha...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
} if me.local_set.tick() { // If `tick` returns `true`, we need to notify the local future again: // there are still tasks remaining in the run queue. cx.waker().wake_by_ref(); } Poll::Pending }) } } impl Shared { ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
// We are *not* on the thread that owns the `LocalSet`, so we // have to wake to the remote queue. _ => { // First, check whether the queue is still there (if not, the // LocalSet is dropped). Then push to it if so, and if not, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
task_terminate_callback: None, } } cfg_unstable! { fn unhandled_panic(&self) { use crate::runtime::UnhandledPanic; match self.unhandled_panic { UnhandledPanic::Ignore => { // Do nothing } UnhandledPanic...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
// The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_thread(); self.local_queue.with_mut(|ptr| (*ptr).push_back(task)); } unsafe fn take_local_queue(&self) -> VecDeque<task::Notified<Arc<Shared>>> { // The caller ensur...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
self.owned.assert_owner(task) } unsafe fn close_and_shutdown_all(&self) { // The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_thread(); self.owned.close_and_shutdown_all(); } #[track_caller] fn assert_cal...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
// borrows violations in the `LocalSet` implementation. #[test] fn local_current_thread_scheduler() { let f = async { LocalSet::new() .run_until(async { spawn_local(async {}).await.unwrap(); }) .await; }; cra...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
1,201
1,260
tokio-rs/tokio:tokio/src/task/local.rs:32
task.await.unwrap(); })); // poll the run until future once std::future::poll_fn(|cx| { let _ = run_until.as_mut().poll(cx); Poll::Ready(()) }) .await; notify.notify_one(); let task = unsafe { local.con...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c3a935541d911cd9afa6838a1bb02e4f499b244d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3a935541d911cd9afa6838a1bb02e4f499b244d/tokio/src/task/local.rs
1,241
1,261
tokio-rs/tokio:tokio/src/task/local.rs:1
//! Runs `!Send` futures on the current thread. use crate::loom::cell::UnsafeCell; use crate::loom::sync::{Arc, Mutex}; #[cfg(tokio_unstable)] use crate::runtime; use crate::runtime::task::{self, JoinHandle, LocalOwnedTasks, Task, TaskHarnessScheduleHooks}; use crate::runtime::{context, ThreadId, BOX_FUTURE_THRESHOLD};...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
1
60
tokio-rs/tokio:tokio/src/task/local.rs:6
/// /// #[tokio::main] /// async fn main() { /// let spawner = LocalSpawner::new(); /// /// let (send, response) = oneshot::channel(); /// spawner.spawn(Task::AddOne(10, send)); /// let eleven = response.await.unwrap(); /// assert_eq!(eleven, 11); /// } /// ``...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:7
struct Shared { /// # Safety /// /// This field must *only* be accessed from the thread that owns the /// `LocalSet` (i.e., `Thread::current().id() == owner`). local_state: LocalState, /// Remote run queue sender. queue: Mutex<Option<VecDeque<task::Notified<Arc<Shared>>>>>, /// Wake th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
tokio_thread_local!(static CURRENT: LocalData = const { LocalData { ctx: RcCell::new(), wake_on_schedule: Cell::new(false), } }); struct LocalData { ctx: RcCell<Context>, wake_on_schedule: Cell<bool>, } impl LocalData { /// Should be called except when we call `LocalSet::enter`. /// Especially...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
cfg_rt! { /// Spawns a `!Send` future on the current [`LocalSet`]. /// /// The spawned future will run on the same thread that called `spawn_local`. /// /// The provided future will start running in the background immediately /// when `spawn_local` is called, even if you don't await the returned...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
/// /// [`LocalSet`]: struct@crate::task::LocalSet /// [`tokio::spawn`]: fn@crate::task::spawn #[track_caller] pub fn spawn_local<F>(future: F) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { if std::mem::size_of::<F>() > BOX_FUTURE_THRESHOLD { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
ctx: Option<Rc<Context>>, /// Distinguishes whether the context was entered or being polled. /// When we enter it, the value `wake_on_schedule` is set. In this case /// `spawn_local` refers the context, whereas it is not being polled now. wake_on_schedule: bool, } impl Drop for LocalEnterGuard { f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
local_queue: UnsafeCell::new(VecDeque::with_capacity(INITIAL_CAPACITY)), }, queue: Mutex::new(Some(VecDeque::with_capacity(INITIAL_CAPACITY))), waker: AtomicWaker::new(), #[cfg(tokio_unstable)] unhandled_panic: crate::ru...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:16
/// This returns a future that runs the given future with a local set, /// allowing it to call [`spawn_local`] to spawn additional `!Send` futures. /// Any local futures spawned on the local set will be driven in the /// background until the future passed to `run_until` completes. When the future /// pa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
#[track_caller] pub(in crate::task) fn spawn_named<F>( &self, future: F, name: Option<&str>, ) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { if std::mem::size_of::<F>() > BOX_FUTURE_THRESHOLD { self.spawn_named_inner...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
// Make sure we didn't hit an unhandled panic assert!(!self.context.unhandled_panic.get(), "a spawned task panicked and the LocalSet is configured to shutdown on unhandled panic"); match self.next_task() { // Run the task // // Safety: As spawned ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
.lock() .as_mut() .and_then(VecDeque::pop_front) }) }; task.map(|task| unsafe { // Safety: because the `LocalSet` itself is `!Send`, we know we are // on the same thread if we have access to the `LocalSet`, and can ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:22
/// ```rust /// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// let local_set = task::LocalSet::new(); /// println!("Local set id: {}", local_set.id()); /// } /// ``` /// /// **Note**: This is an [unstable API][uns...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
841
900
tokio-rs/tokio:tokio/src/task/local.rs:23
// Safety: called from the thread that owns `LocalSet`. Because // `LocalSet` is `!Send`, this is safe. } else if unsafe { self.context.shared.local_state.owned_is_empty() } { // If the scheduler has no remaining futures, we're done! Poll::Ready(()) } else { /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
// dropped *before* the `LocalSet`. // // Despite avoiding the assertion here, it is safe for us to access // the local queue in `Drop`, because the `LocalSet` itself is // `!Send`, so we can reasonably guarantee that it will not be // `Drop`ped from another t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
let (handle, notified) = { self.shared.local_state.assert_called_from_owner_thread(); self.shared .local_state .owned .bind(future, self.shared.clone(), id) }; if let Some(notified) = notified { self.shared.schedule(not...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
// there are still tasks remaining in the run queue. cx.waker().wake_by_ref(); } Poll::Pending }) } } impl Shared { /// Schedule the provided task on the scheduler. fn schedule(&self, task: task::Notified<Arc<Self>>) { CURRENT.with(|localdata| { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
// LocalSet is dropped). Then push to it if so, and if not, // do nothing. let mut lock = self.queue.lock(); if let Some(queue) = lock.as_mut() { queue.push_back(task); drop(lock); self.w...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
cfg_unstable! { fn unhandled_panic(&self) { use crate::runtime::UnhandledPanic; match self.unhandled_panic { UnhandledPanic::Ignore => { // Do nothing } UnhandledPanic::ShutdownRuntime => { // This h...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
self.local_queue.with_mut(|ptr| (*ptr).push_back(task)); } unsafe fn take_local_queue(&self) -> VecDeque<task::Notified<Arc<Shared>>> { // The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_thread(); self.local_queue.wi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
// The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_thread(); self.owned.close_and_shutdown_all(); } #[track_caller] fn assert_called_from_owner_thread(&self) { // FreeBSD has some weirdness around thread-local de...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
LocalSet::new() .run_until(async { spawn_local(async {}).await.unwrap(); }) .await; }; crate::runtime::Builder::new_current_thread() .build() .expect("rt") .block_on(f) } // Tests that when a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
1,201
1,257
tokio-rs/tokio:tokio/src/task/local.rs:32
std::future::poll_fn(|cx| { let _ = run_until.as_mut().poll(cx); Poll::Ready(()) }) .await; notify.notify_one(); let task = unsafe { local.context.shared.local_state.task_pop_front() }; // TODO(eliza): it would be nice to be ab...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b5de84d19b4316caccfe13aa7552d895bdd7f046
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b5de84d19b4316caccfe13aa7552d895bdd7f046/tokio/src/task/local.rs
1,241
1,257
tokio-rs/tokio:tokio/src/task/local.rs:9
cfg_rt! { /// Spawns a `!Send` future on the current [`LocalSet`]. /// /// The spawned future will run on the same thread that called `spawn_local`. /// /// The provided future will start running in the background immediately /// when `spawn_local` is called, even if you don't await the returned...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
/// /// [`LocalSet`]: struct@crate::task::LocalSet /// [`tokio::spawn`]: fn@crate::task::spawn #[track_caller] pub fn spawn_local<F>(future: F) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { if cfg!(debug_assertions) && std::mem::size_of::<F>() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/local.rs
361
420