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:11
F: Future + 'static, F::Output: 'static, { let fut_size = std::mem::size_of::<F>(); if fut_size > BOX_FUTURE_THRESHOLD { spawn_local_inner(Box::pin(future), SpawnMeta::new_unnamed(fut_size)) } else { spawn_local_inner(future, SpawnMeta::new_unnamed(fut_size)) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
let future = task::trace::Trace::root(future); let id = task::Id::next(); let task = crate::util::trace::task(future, "task", meta, id.as_u64()); // safety: we have verified that this is a `LocalRuntime` owned by the current thread unsafe { handle.spawn_l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
/// `spawn_local` refers the context, whereas it is not being polled now. wake_on_schedule: bool, } impl Drop for LocalEnterGuard { fn drop(&mut self) { CURRENT.with( |LocalData { ctx, wake_on_schedule, }| { ctx.set(self.ctx.tak...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
#[cfg(tokio_unstable)] unhandled_panic: crate::runtime::UnhandledPanic::Ignore, }), unhandled_panic: Cell::new(false), }), _not_send: PhantomData, } } /// Enters the context of this `LocalSet`. /// /// The [`spawn_local...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:18
} /// 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. /// Any local futures spawned on the local set will be driven in the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
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: Future + 'static, F::Output: 'static, { self.spawn_named_inner(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:20
// 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
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
.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
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:24
/// }) /// .await; /// # } /// ``` /// /// [`JoinHandle`]: struct@crate::task::JoinHandle pub fn unhandled_panic(&mut self, behavior: crate::runtime::UnhandledPanic) -> &mut Self { // TODO: This should be set as a builder Rc::get_mut(&mut s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
} else if unsafe { self.context.shared.local_state.owned_is_empty() } { // If the scheduler has no remaining futures, we're done! Poll::Ready(()) } else { // There are still futures in the local set, but we've polled all the // futures in the run queue. Therefore,...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
// // 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 thread. let local_queue = unsafe { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
self.shared.local_state.assert_called_from_owner_thread(); self.shared.local_state.owned.bind( future, self.shared.clone(), id, SpawnLocation::capture(), ) }; if let Some(notified) = notified { self.shar...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
// 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 { /// Schedule the provided task on the scheduler. fn sch...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
// First, check whether the queue is still there (if not, the // 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.p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
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
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
/// # Safety /// /// This method must only be called from the thread who /// has the same [`ThreadId`] as [`Self::owner`]. 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....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
1,201
1,260
tokio-rs/tokio:tokio/src/task/local.rs:32
self.owned.is_empty() } 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....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
1,241
1,300
tokio-rs/tokio:tokio/src/task/local.rs:33
// This is `Send` because it is stored in `Shared`. It is up to the caller to // ensure they are on the same thread that owns the `LocalSet`. 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? ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
1,281
1,340
tokio-rs/tokio:tokio/src/task/local.rs:34
.build() .expect("rt"); 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; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
231a3a69f9a191c88b94a9ff141865f9a8d0bf84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/231a3a69f9a191c88b94a9ff141865f9a8d0bf84/tokio/src/task/local.rs
1,321
1,353
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, SpawnLocation, Task, TaskHarnessScheduleHooks, }; use crate::runtime::{context, ThreadId, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
1
60
tokio-rs/tokio:tokio/src/task/local.rs:6
/// Task::AddOne(n, response) => { /// // We ignore failures to send the response. /// let _ = response.send(n + 1); /// }, /// } /// } /// /// #[tokio::main] /// async fn main() { /// let spawner = LocalSpawner::new(); /// /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:7
/// True if a task panicked without being handled and the local set is /// configured to shutdown on unhandled panic. unhandled_panic: Cell<bool>, } /// `LocalSet` state shared between threads. struct Shared { /// # Safety /// /// This field must *only* be accessed from the thread that owns the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
struct RunUntil<'a, F> { local_set: &'a LocalSet, #[pin] future: F, } } 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>, }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:10
/// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { /// let nonsend_data = Rc::new("my nonsend data..."); /// /// let local = task::LocalSet::new(); /// /// // Run the local task set. /// local.run_until(async move { /// let nonsend_data = nonsend_data.clo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
where F: Future + 'static, F::Output: 'static, { let fut_size = std::mem::size_of::<F>(); if fut_size > BOX_FUTURE_THRESHOLD { spawn_local_inner(Box::pin(future), SpawnMeta::new_unnamed(fut_size)) } else { spawn_local_inner(future, SpawnMeta::new_unnam...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
))] let future = task::trace::Trace::root(future); let id = task::Id::next(); let task = crate::util::trace::task(future, "task", meta, id.as_u64()); // safety: we have verified that this is a `LocalRuntime` owned by the current thread uns...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
/// 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 { fn drop(&mut self) { CURRENT.with( |LocalData { ctx, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
waker: AtomicWaker::new(), #[cfg(tokio_unstable)] unhandled_panic: crate::runtime::UnhandledPanic::Ignore, }), unhandled_panic: Cell::new(false), }), _not_send: PhantomData, } } /// Enters the context of thi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:18
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. /// Any local futures spawned on ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
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: Future + 'static, F::Output: 'static, { sel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:20
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 LocalSet is configured to shutdown on unhandled panic"); match self.next_task() { // Run the task ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
.queue .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 `Loca...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:24
/// /// ```rust /// use tokio::task; /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { /// let local_set = task::LocalSet::new(); /// println!("Local set id: {}", local_set.id()); /// # } /// ``` /// /// **...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
// 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. } else if unsafe { self.context.shared.local_state.owned_is_empty() } { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
// `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), attempting to get the current thread ID can panic due // to the threa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
{ 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(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
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 local future again: // there are still tasks remaining in the run queue. cx.waker()...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
self.waker.wake(); } // 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). T...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
// localset does not currently support task hooks fn hooks(&self) -> TaskHarnessScheduleHooks { TaskHarnessScheduleHooks { task_terminate_callback: None, } } cfg_unstable! { fn unhandled_panic(&self) { use crate::runtime::UnhandledPanic; match se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
// the LocalSet. self.assert_called_from_owner_thread(); self.local_queue .with_mut(|ptr| unsafe { (*ptr).pop_front() }) } /// # Safety /// /// This method must only be called from the thread who /// has the same [`ThreadId`] as [`Self::owner`]. unsafe fn task_push_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
1,201
1,260
tokio-rs/tokio:tokio/src/task/local.rs:32
/// Returns true if the `LocalSet` does not have any spawned tasks unsafe fn owned_is_empty(&self) -> bool { // The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_thread(); self.owned.is_empty() } unsafe fn assert_o...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
1,241
1,300
tokio-rs/tokio:tokio/src/task/local.rs:33
.unwrap_or(true), "`LocalSet`'s local run queue must not be accessed by another thread!" ); } } // This is `Send` because it is stored in `Shared`. It is up to the caller to // ensure they are on the same thread that owns the `LocalSet`. unsafe impl Send for LocalState {} #[cfg(all(test, not(l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
1,281
1,340
tokio-rs/tokio:tokio/src/task/local.rs:34
// internal state. #[test] fn wakes_to_local_queue() { use super::*; use crate::sync::Notify; let rt = crate::runtime::Builder::new_current_thread() .build() .expect("rt"); rt.block_on(async { let local = LocalSet::new(); let notify...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0fa7755e97b2b4ba4630d21a6d5316f39aaa4ee5/tokio/src/task/local.rs
1,321
1,359
tokio-rs/tokio:tokio/src/task/local.rs:24
/// /// ```rust /// use tokio::task; /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { /// let local_set = task::LocalSet::new(); /// println!("Local set id: {}", local_set.id()); /// # } /// ``` /// /// **...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:30
// localset does not currently support task hooks fn hooks(&self) -> TaskHarnessScheduleHooks { TaskHarnessScheduleHooks { task_terminate_callback: None, } } cfg_unstable! { fn unhandled_panic(&self) { use crate::runtime::UnhandledPanic; match se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
444d3f5c49ebc8449ba4feccae5bb1a740313953
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444d3f5c49ebc8449ba4feccae5bb1a740313953/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
} 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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
444d3f5c49ebc8449ba4feccae5bb1a740313953
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444d3f5c49ebc8449ba4feccae5bb1a740313953/tokio/src/task/local.rs
1,201
1,260
tokio-rs/tokio:tokio/src/task/local.rs:32
// the LocalSet. 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.ow...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
444d3f5c49ebc8449ba4feccae5bb1a740313953
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444d3f5c49ebc8449ba4feccae5bb1a740313953/tokio/src/task/local.rs
1,241
1,300
tokio-rs/tokio:tokio/src/task/local.rs:33
// // 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 { LocalS...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
444d3f5c49ebc8449ba4feccae5bb1a740313953
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444d3f5c49ebc8449ba4feccae5bb1a740313953/tokio/src/task/local.rs
1,281
1,340
tokio-rs/tokio:tokio/src/task/local.rs:34
} }); 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
444d3f5c49ebc8449ba4feccae5bb1a740313953
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444d3f5c49ebc8449ba4feccae5bb1a740313953/tokio/src/task/local.rs
1,321
1,344
tokio-rs/tokio:tokio/src/task/local.rs:10
/// # async fn main() { /// let nonsend_data = Rc::new("my nonsend data..."); /// /// let local = task::LocalSet::new(); /// /// // Run the local task set. /// local.run_until(async move { /// let nonsend_data = nonsend_data.clone(); /// task::spawn_local(async move { /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
let mut future = Some(future); let res = context::with_current(|handle| { Some(if handle.is_local() { if !handle.can_spawn_local_on_local_runtime() { return None; } let future = future.take().unwrap(); #[cfg(all( ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
None => panic!("`spawn_local` called from outside of a `task::LocalSet` or `runtime::LocalRuntime`"), Some(cx) => cx.spawn(future.unwrap(), meta) } } } } /// Initial queue capacity. const INITIAL_CAPACITY: usize = 64; /// Max number of tasks to poll per tick. const MAX_TASKS_PE...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
impl fmt::Debug for LocalEnterGuard { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("LocalEnterGuard").finish() } } impl LocalSet { /// Returns a new local task set. pub fn new() -> LocalSet { let owner = context::thread_id().expect("cannot create LocalSet du...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
ctx, wake_on_schedule, .. }| { let ctx = ctx.replace(Some(self.context.clone())); let wake_on_schedule = wake_on_schedule.replace(true); LocalEnterGuard { ctx, wake_on_schedule, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:18
/// ```rust /// use tokio::task; /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() { /// task::LocalSet::new().run_until(async { /// task::spawn_local(async move { /// // ... /// }).await.unwrap(); /// // ... /// }).await; /// # } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
#[track_caller] fn spawn_named_inner<F>(&self, future: F, meta: SpawnMeta<'_>) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { let handle = self.context.spawn(future, meta); // Because a task was spawned from *outside* the `LocalSet`, wake the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:20
} true } fn next_task(&self) -> Option<task::LocalNotified<Arc<Shared>>> { let tick = self.tick.get(); self.tick.set(tick.wrapping_add(1)); let task = if tick % REMOTE_FIRST_INTERVAL == 0 { self.context .shared .queue ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
// therefore access the local run queue. self.context.shared.local_state.task_pop_front() } } fn with<T>(&self, f: impl FnOnce() -> T) -> T { CURRENT.with(|local_data| { let _guard = local_data.enter(self.context.clone()); f() }) } /// This m...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:23
/// /// // Do some work, but `run_until` will panic before it completes /// # loop { tokio::task::yield_now().await; } /// }) /// .await; /// # } /// ``` /// /// [`JoinHandle`]: struct@crate::task::JoinHandle pub fn unhandled_panic(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
} } } impl fmt::Debug for LocalSet { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("LocalSet").finish() } } impl Future for LocalSet { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> { let _no_b...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
fn default() -> LocalSet { LocalSet::new() } } impl Drop for LocalSet { fn drop(&mut self) { self.with_if_possible(|| { let _no_blocking = crate::runtime::context::disallow_block_in_place(); // Shut down all tasks in the LocalOwnedTasks and close it to // pr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
// Take the queue from the Shared object to prevent pushing // notifications to it in the future. let queue = self.context.shared.queue.lock().take().unwrap(); for task in queue { drop(task); } // Safety: called from the thread that owns `Loca...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
handle } } // === impl LocalFuture === impl<T: Future> Future for RunUntil<'_, T> { type Output = T::Output; fn poll(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> { let me = self.project(); me.local_set.with(|| { me.local_set .co...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
CURRENT.with(|localdata| { match localdata.ctx.get() { // If the current `LocalSet` is being polled, we don't need to wake it. // When we `enter` it, then the value `wake_on_schedule` is set to be true. // In this case it is not being polled, so we need to wak...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
} fn ptr_eq(&self, other: &Shared) -> bool { std::ptr::eq(self, other) } } // This is safe because (and only because) we *pinky pwomise* to never touch the // local run queue except from the thread that owns the `LocalSet`. unsafe impl Sync for Shared {} impl task::Schedule for Arc<Shared> { fn r...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
CURRENT.with(|LocalData { ctx, .. }| match ctx.get() { Some(cx) if Arc::ptr_eq(self, &cx.shared) => { cx.unhandled_panic.set(true); // Safety: this is always called from the thread that owns `LocalSet` unsafe { c...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
// The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_thread(); self.owned.remove(task) } /// Returns true if the `LocalSet` does not have any spawned tasks unsafe fn owned_is_empty(&self) -> bool { // The caller en...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
1,201
1,260
tokio-rs/tokio:tokio/src/task/local.rs:32
debug_assert!( // if we couldn't get the thread ID because we're dropping the local // data, skip the assertion --- the `Drop` impl is not going to be // called from another thread, because `LocalSet` is `!Send` context::thread_id() .map(|id| id == self.ow...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
1,241
1,300
tokio-rs/tokio:tokio/src/task/local.rs:33
// Tests that when a task on a `LocalSet` is woken by an io driver on the // same thread, the task is woken to the localset's local queue rather than // its remote queue. // // This test has to be defined in the `local.rs` file as a lib test, rather // than in `tests/`, because it makes assertions a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c1fa25f3009d6f5374e337b999fe4fe926c8e7f2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/local.rs
1,281
1,325
tokio-rs/tokio:tokio/src/task/local.rs:11
let mut future = Some(future); let res = context::with_current(|handle| { Some(if handle.is_local() { if !handle.can_spawn_local_on_local_runtime() { return None; } let future = future.take().unwrap(); #[cfg(all( ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
d1f1499f630c34c1d319acdc2cc86d7a1008c4b4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
None => panic!("`spawn_local` called from outside of a `task::LocalSet` or LocalRuntime"), Some(cx) => cx.spawn(future.unwrap(), meta) } } } } /// Initial queue capacity. const INITIAL_CAPACITY: usize = 64; /// Max number of tasks to poll per tick. const MAX_TASKS_PER_TICK: usi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
d1f1499f630c34c1d319acdc2cc86d7a1008c4b4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:10
/// # async fn main() { /// let nonsend_data = Rc::new("my nonsend data..."); /// /// let local = task::LocalSet::new(); /// /// // Run the local task set. /// local.run_until(async move { /// let nonsend_data = nonsend_data.clone(); /// task::spawn_local(async move { /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
let mut future = Some(future); let res = context::with_current(|handle| { Some(if handle.is_local() { if !handle.can_spawn_local_on_local_runtime() { return None; } let future = future.take().unwrap(); #[cfg(all( ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:6
/// let _ = response.send(n + 1); /// }, /// } /// } /// /// #[tokio::main] /// async fn main() { /// let spawner = LocalSpawner::new(); /// /// let (send, response) = oneshot::channel(); /// spawner.spawn(Task::AddOne(10, send)); /// l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:7
unhandled_panic: Cell<bool>, } /// `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. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
future: F, } } 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`...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:10
/// let local = task::LocalSet::new(); /// /// // Run the local task set. /// local.run_until(async move { /// let nonsend_data = nonsend_data.clone(); /// task::spawn_local(async move { /// println!("{}", nonsend_data); /// // ... /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
let res = context::with_current(|handle| { Some(if handle.is_local() { if !handle.can_spawn_local_on_local_runtime() { return None; } let future = future.take().unwrap(); #[cfg(all( tokio_unstable, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
} } } /// Initial queue capacity. const INITIAL_CAPACITY: usize = 64; /// Max number of tasks to poll per tick. const MAX_TASKS_PER_TICK: usize = 61; /// How often it check the remote queue first. const REMOTE_FIRST_INTERVAL: u8 = 31; /// Context guard for `LocalSet` pub struct LocalEnterGuard { ctx: Option...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
} } impl LocalSet { /// Returns a new local task set. pub fn new() -> LocalSet { let owner = context::thread_id().expect("cannot create LocalSet during thread shutdown"); LocalSet { tick: Cell::new(0), context: Rc::new(Context { shared: Arc::new(Shared {...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
}| { let ctx = ctx.replace(Some(self.context.clone())); let wake_on_schedule = wake_on_schedule.replace(true); LocalEnterGuard { ctx, wake_on_schedule, } }, ) } /// Spawns a `!Send` task ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:17
/// join.await.unwrap(); /// }) /// ``` /// /// [`spawn_local`]: fn@spawn_local /// [`Runtime::block_on`]: method@crate::runtime::Runtime::block_on /// [in-place blocking]: fn@crate::task::block_in_place /// [`spawn_blocking`]: fn@crate::task::spawn_blocking #[track_caller] #[cfg...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
/// task::spawn_local(async move { /// // ... /// }).await.unwrap(); /// // ... /// }).await; /// } /// ``` /// /// [`spawn_local`]: fn@spawn_local /// [awaiting the local set]: #awaiting-a-localset pub async fn run_until<F>(&self, future: ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
let handle = self.context.spawn(future, meta); // Because a task was spawned from *outside* the `LocalSet`, wake the // `LocalSet` future to execute the new task, if it hasn't been woken. // // Spawning via the free fn `spawn` does not require this, as it can // only be called f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:20
let tick = self.tick.get(); self.tick.set(tick.wrapping_add(1)); let task = if tick % REMOTE_FIRST_INTERVAL == 0 { self.context .shared .queue .lock() .as_mut() .and_then(|queue| queue.pop_front()) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
CURRENT.with(|local_data| { let _guard = local_data.enter(self.context.clone()); f() }) } /// This method is like `with`, but it just calls `f` without setting the thread-local if that /// fails. fn with_if_possible<T>(&self, f: impl FnOnce() -> T) -> T { let mut...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:23
/// ``` /// /// [`JoinHandle`]: struct@crate::task::JoinHandle pub fn unhandled_panic(&mut self, behavior: crate::runtime::UnhandledPanic) -> &mut Self { // TODO: This should be set as a builder Rc::get_mut(&mut self.context) .and_then(|ctx| Arc::get_mut(&...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
fmt.debug_struct("LocalSet").finish() } } impl Future for LocalSet { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> { let _no_blocking = crate::runtime::context::disallow_block_in_place(); // Register the waker before starting to wor...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
fn drop(&mut self) { self.with_if_possible(|| { let _no_blocking = crate::runtime::context::disallow_block_in_place(); // Shut down all tasks in the LocalOwnedTasks and close it to // prevent new tasks from ever being added. unsafe { // Safety: ca...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
// Safety: called from the thread that owns `LocalSet` assert!(unsafe { self.context.shared.local_state.owned_is_empty() }); }); } } // === impl Context === impl Context { #[track_caller] fn spawn<F>(&self, future: F, meta: SpawnMeta<'_>) -> JoinHandle<F::Output> where F: F...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
impl<T: Future> Future for RunUntil<'_, T> { type Output = T::Output; fn poll(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> { let me = self.project(); me.local_set.with(|| { me.local_set .context .shared ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
// Safety: if the current `LocalSet` context points to this // `LocalSet`, then we are on the thread that owns it. cx.shared.local_state.task_push_back(task); }, // We are on the thread that owns the `LocalSet`, so we can // wake t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
// This is safe because (and only because) we *pinky pwomise* to never touch the // local run queue except from the thread that owns the `LocalSet`. unsafe impl Sync for Shared {} impl task::Schedule for Arc<Shared> { fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { // Safety, this is always ca...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
_ => unreachable!("runtime core not set in CURRENT thread-local"), }) } } } } } 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 //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4b96af6040b0136d3fd147b28e3775961f6a3d0a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4b96af6040b0136d3fd147b28e3775961f6a3d0a/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:8
future: F, } } 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`...
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
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
.wake_on_schedule .set(self.wake_on_schedule) } } 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...
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
321
380
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
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/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
a0d5b8ab308bbeaa8090d411550d6c887d699096
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a0d5b8ab308bbeaa8090d411550d6c887d699096/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
const MAX_TASKS_PER_TICK: usize = 61; /// 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 v...
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
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
LocalSet { tick: Cell::new(0), context: Rc::new(Context { shared: Arc::new(Shared { local_state: LocalState { owner, owned: LocalOwnedTasks::new(), local_queue: UnsafeCell::new(VecDeque::w...
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
481
540