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: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
12b2567b959ec754e6f58fb76b88a1a38f805771
github
async-runtime
https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/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 cfg!(debug_assertions) && std::mem::size_of::<F>() > BOX_FUTURE_THRESHOLD { ...
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
641
700
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
b37f0de28a17ced6a9e6738062770d6fea8c5364
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/task/local.rs
1,201
1,257
tokio-rs/tokio:tokio/src/task/local.rs:32
crate::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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b37f0de28a17ced6a9e6738062770d6fea8c5364
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/task/local.rs
1,241
1,257
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}; use crate::runtime::{context, ThreadId, BOX_FUTURE_THRESHOLD}; use crate::sync::AtomicWa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
da17c6146413d9ea14f76989efe31ef7de829f4c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/da17c6146413d9ea14f76989efe31ef7de829f4c/tokio/src/task/local.rs
1
60
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
da17c6146413d9ea14f76989efe31ef7de829f4c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/da17c6146413d9ea14f76989efe31ef7de829f4c/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
} UnhandledPanic::ShutdownRuntime => { // This hook is only called from within the runtime, so // `CURRENT` should match with `&self`, i.e. there is no // opportunity for a nested scheduler to be called. CURRENT.with(|LocalD...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
da17c6146413d9ea14f76989efe31ef7de829f4c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/da17c6146413d9ea14f76989efe31ef7de829f4c/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
self.local_queue.with_mut(|ptr| std::mem::take(&mut (*ptr))) } unsafe fn task_remove(&self, task: &Task<Arc<Shared>>) -> Option<Task<Arc<Shared>>> { // The caller ensures it is called from the same thread that owns // the LocalSet. self.assert_called_from_owner_thread(); self.o...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
da17c6146413d9ea14f76989efe31ef7de829f4c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/da17c6146413d9ea14f76989efe31ef7de829f4c/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
#[track_caller] fn assert_called_from_owner_thread(&self) { // FreeBSD has some weirdness around thread-local destruction. // TODO: remove this hack when thread id is cleaned up #[cfg(not(any(target_os = "openbsd", target_os = "freebsd")))] debug_assert!( // if we couldn'...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
da17c6146413d9ea14f76989efe31ef7de829f4c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/da17c6146413d9ea14f76989efe31ef7de829f4c/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
.build() .expect("rt") .block_on(f) } // 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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
da17c6146413d9ea14f76989efe31ef7de829f4c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/da17c6146413d9ea14f76989efe31ef7de829f4c/tokio/src/task/local.rs
1,201
1,250
tokio-rs/tokio:tokio/src/task/local.rs:32
let task = unsafe { local.context.shared.local_state.task_pop_front() }; // TODO(eliza): it would be nice to be able to assert that this is // the local task. assert!( task.is_some(), "task should have been notified to the LocalSet's local queue" ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
da17c6146413d9ea14f76989efe31ef7de829f4c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/da17c6146413d9ea14f76989efe31ef7de829f4c/tokio/src/task/local.rs
1,241
1,250
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}; use crate::runtime::{context, ThreadId}; use crate::sync::AtomicWaker; use crate::util::...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
1
60
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
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/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, { spawn_local_inner(future, None) } #[track_ca...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:12
#[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
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:16
/// passed to `run_until` finishes, any local futures which have not completed /// will remain on the local set, and will be driven on subsequent calls to /// `run_until` or when [awaiting the local set] itself. /// /// # Cancel safety /// /// This method is cancel safe when `future` is cancel s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
future: F, name: Option<&str>, ) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { let handle = self.context.spawn(future, name); // Because a task was spawned from *outside* the `LocalSet`, wake the // `LocalSet` future to execute the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
} } 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
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
// on the same thread if we have access to the `LocalSet`, and can // 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_dat...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:21
/// }); /// /// // Do some work, but `run_until` will panic before it completes /// # loop { tokio::task::yield_now().await; } /// }) /// .await; /// # } /// ``` /// /// [`JoinHandle`]: struct@crate::task::JoinHandle ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:22
self.context.shared.local_state.owned.id.into() } } } 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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
841
900
tokio-rs/tokio:tokio/src/task/local.rs:23
LocalSet::new() } } impl Drop for LocalSet { fn drop(&mut self) { self.with_if_possible(|| { // Shut down all tasks in the LocalOwnedTasks and close it to // prevent new tasks from ever being added. unsafe { // Safety: called from the thread that owns...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
for task in queue { drop(task); } // 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, futu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
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
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
Some(cx) if cx.shared.ptr_eq(self) && !localdata.wake_on_schedule.get() => unsafe { // 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); }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
} // 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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
} 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()) } uns...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:30
// 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
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
.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
97bb47b480c66083397c21d54e7ae33cab6c1b20
github
async-runtime
https://github.com/tokio-rs/tokio/blob/97bb47b480c66083397c21d54e7ae33cab6c1b20/tokio/src/task/local.rs
1,201
1,233
tokio-rs/tokio:tokio/src/task/local.rs:16
/// passed to `run` finishes, any local futures which have not completed /// will remain on the local set, and will be driven on subsequent calls to /// `run_until` or when [awaiting the local set] itself. /// /// # Cancel safety /// /// This method is cancel safe when `future` is cancel safe. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
131e7b4e49c8849298ba54b4e0c99f4b81d869e3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/task/local.rs
601
660
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
340d4e5238f7feaee63978c541559e0a127733bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/340d4e5238f7feaee63978c541559e0a127733bf/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
340d4e5238f7feaee63978c541559e0a127733bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/340d4e5238f7feaee63978c541559e0a127733bf/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
340d4e5238f7feaee63978c541559e0a127733bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/340d4e5238f7feaee63978c541559e0a127733bf/tokio/src/task/local.rs
281
340
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, { spawn_local_inner(future, None) } #[track_ca...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
340d4e5238f7feaee63978c541559e0a127733bf
github
async-runtime
https://github.com/tokio-rs/tokio/blob/340d4e5238f7feaee63978c541559e0a127733bf/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:29
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
d44e995bb00738d670edb33246ad25375df40638
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d44e995bb00738d670edb33246ad25375df40638/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
// 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
d44e995bb00738d670edb33246ad25375df40638
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d44e995bb00738d670edb33246ad25375df40638/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:16
/// passed to `run` finishes, any local futures which have not completed /// will remain on the local set, and will be driven on subsequent calls to /// `run_until` or when [awaiting the local set] itself. /// /// # Examples /// /// ```rust /// use tokio::task; /// /// #[tokio::main]...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
F: Future + 'static, F::Output: 'static, { let handle = self.context.spawn(future, name); // 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 `spaw...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
} 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 .lock() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
} fn with<T>(&self, f: impl FnOnce() -> T) -> T { 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_p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:21
/// }) /// .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
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:22
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> { // Register the wake...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
841
900
tokio-rs/tokio:tokio/src/task/local.rs:23
impl Drop for LocalSet { fn drop(&mut self) { self.with_if_possible(|| { // Shut down all tasks in the LocalOwnedTasks and close it to // prevent new tasks from ever being added. unsafe { // Safety: called from the thread that owns `LocalSet` ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
// 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, name: Option<&str>) -> JoinHandle<F::Output> where F: Fu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
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 .waker .register_by_ref(cx.waker()); let _no_bloc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
}, // We are on the thread that owns the `LocalSet`, so we can // wake to the local queue. _ if context::thread_id().ok() == Some(self.local_state.owner) => { unsafe { // Safety: we just checked that the thread ID matches ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
unsafe impl Sync for Shared {} impl task::Schedule for Arc<Shared> { fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { // Safety, this is always called from the thread that owns `LocalSet` unsafe { self.local_state.task_remove(task) } } fn schedule(&self, task: task::Notified<Se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
// 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 fn task_push_back(&self, task: task::Notified<Arc<Shared>>) { // The caller ensures it is call...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
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
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
#[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 wil run under Miri, so this is necessary to catch stacked // borrows...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
let notify = Arc::new(Notify::new()); let task = local.spawn_local({ let notify = notify.clone(); async move { notify.notified().await; } }); let mut run_until = Box::pin(local.run_until(async move { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/local.rs
1,201
1,229
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, { spawn_local_inner(future, None) } #[track_ca...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
/// `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
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:17
F: Future + 'static, F::Output: 'static, { let handle = self.context.spawn(future, name); // 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 `spaw...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
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 .lock() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
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 method is like `with`, but it just calls `f` without s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:21
/// // 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(&mut self, b...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:22
} } 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> { // Register the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
841
900
tokio-rs/tokio:tokio/src/task/local.rs:23
} impl Drop for LocalSet { fn drop(&mut self) { self.with_if_possible(|| { // Shut down all tasks in the LocalOwnedTasks and close it to // prevent new tasks from ever being added. unsafe { // Safety: called from the thread that owns `LocalSet` ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
} // 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, name: Option<&str>) -> JoinHandle<F::Output> wher...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
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 .waker .register_by_ref(cx.waker...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
// `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 to the local queue. _ if context::thread_id().ok() == Some(self.l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
// 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
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
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
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
} 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
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
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 wil run under Miri, so this is neces...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
1,161
1,220
tokio-rs/tokio:tokio/src/task/local.rs:31
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
f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ad6cffd90eb54a56e8ed4c6f627f1c2f64bea1/tokio/src/task/local.rs
1,201
1,231
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
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/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(), } }); struct LocalData { ctx: RcCell<Context>, } cfg_rt! { /// Spawns a `!Send` future on the current [`LocalSet`]. /// /// The spawned future will run on the same thread that called `spawn_local`. /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
/// task::spawn_local(async move { /// println!("{}", nonsend_data); /// // ... /// }).await.unwrap(); /// }).await; /// } /// ``` /// /// [`LocalSet`]: struct@crate::task::LocalSet /// [`tokio::spawn`]: fn@crate::task::spawn #[track_ca...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
/// Context guard for LocalSet pub struct LocalEnterGuard(Option<Rc<Context>>); impl Drop for LocalEnterGuard { fn drop(&mut self) { CURRENT.with(|LocalData { ctx, .. }| { ctx.set(self.0.take()); }) } } impl fmt::Debug for LocalEnterGuard { fn fmt(&self, f: &mut fmt::Formatter<...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:14
/// 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
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
/// }).await; /// } /// ``` /// /// [`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: sel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
/// notified again. fn tick(&self) -> bool { for _ in 0..MAX_TASKS_PER_TICK { // Make sure we didn't hit an unhandled panic if self.context.unhandled_panic.get() { panic!("a spawned task panicked and the LocalSet is configured to shutdown on unhandled panic"); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
} else { self.pop_local().or_else(|| { self.context .shared .queue .lock() .as_mut() .and_then(|queue| queue.pop_front()) }) }; task.map(|task| unsafe { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
let _reset = Reset { ctx_ref: ctx, val: old, }; 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
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:20
/// /// ```should_panic /// use tokio::runtime::UnhandledPanic; /// /// # #[tokio::main] /// # async fn main() { /// tokio::task::LocalSet::new() /// .unhandled_panic(UnhandledPanic::ShutdownRuntime) /// .run_until(async { /// tokio...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
/// let local_set = task::LocalSet::new(); /// println!("Local set id: {}", local_set.id()); /// } /// ``` /// /// **Note**: This is an [unstable API][unstable]. The public API of this type /// may break in 1.x releases. See [the documentation on unstable ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:22
Poll::Ready(()) } else { // There are still futures in the local set, but we've polled all the // futures in the run queue. Therefore, we can just return Pending // since the remaining futures will be woken from somewhere else. Poll::Pending } } } imp...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
841
900
tokio-rs/tokio:tokio/src/task/local.rs:23
// `Drop`ped from another thread. let local_queue = unsafe { // Safety: called from the thread that owns `LocalSet` self.context.shared.local_state.take_local_queue() }; for task in local_queue { drop(task); } /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
.bind(future, self.shared.clone(), id) }; if let Some(notified) = notified { self.shared.schedule(notified); } handle } } // === impl LocalFuture === impl<T: Future> Future for RunUntil<'_, T> { type Output = T::Output; fn poll(self: Pin<&mut Self>, cx: &mut ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
}) } } impl Shared { /// Schedule the provided task on the scheduler. fn schedule(&self, task: task::Notified<Arc<Self>>) { CURRENT.with(|localdata| { match localdata.ctx.get() { Some(cx) if cx.shared.ptr_eq(self) => unsafe { // Safety: if the current...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
} } } }); } 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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
// Safety: this is always called from the thread that owns `LocalSet` unsafe { cx.shared.local_state.close_and_shutdown_all(); } } _ => unreachable!("runtime core not set in CURRENT thread-local"), }) } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
1,041
1,100
tokio-rs/tokio:tokio/src/task/local.rs:28
self.owned.remove(task) } /// 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_em...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
1,081
1,140
tokio-rs/tokio:tokio/src/task/local.rs:29
// called from another thread, because `LocalSet` is `!Send` context::thread_id() .map(|id| id == self.owner) .unwrap_or(true), "`LocalSet`'s local run queue must not be accessed by another thread!" ); } } // This is `Send` because it is stored in `Sh...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
1,121
1,180
tokio-rs/tokio:tokio/src/task/local.rs:30
// // This test has to be defined in the `local.rs` file as a lib test, rather // than in `tests/`, because it makes assertions about the local set's // internal state. #[test] fn wakes_to_local_queue() { use super::*; use crate::sync::Notify; let rt = crate::runtime::Builder...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
aad1892ab5b6d4e5e75f7ba03e72166f022e08ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aad1892ab5b6d4e5e75f7ba03e72166f022e08ee/tokio/src/task/local.rs
1,161
1,202
tokio-rs/tokio:tokio/src/task/local.rs:14
/// 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
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
/// }).await; /// } /// ``` /// /// [`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: sel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
fn tick(&self) -> bool { for _ in 0..MAX_TASKS_PER_TICK { // Make sure we didn't hit an unhandled panic if self.context.unhandled_panic.get() { panic!("a spawned task panicked and the LocalSet is configured to shutdown on unhandled panic"); } matc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
self.pop_local().or_else(|| { self.context .shared .queue .lock() .as_mut() .and_then(|queue| queue.pop_front()) }) }; task.map(|task| unsafe { // Safety: because ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
let _reset = Reset { ctx_ref: ctx, val: old, }; 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
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:20
/// ```should_panic /// use tokio::runtime::UnhandledPanic; /// /// # #[tokio::main] /// # async fn main() { /// tokio::task::LocalSet::new() /// .unhandled_panic(UnhandledPanic::ShutdownRuntime) /// .run_until(async { /// tokio::task::spaw...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
/// println!("Local set id: {}", local_set.id()); /// } /// ``` /// /// **Note**: This is an [unstable API][unstable]. The public API of this type /// may break in 1.x releases. See [the documentation on unstable /// features][unstable] for details. /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:22
} else { // There are still futures in the local set, but we've polled all the // futures in the run queue. Therefore, we can just return Pending // since the remaining futures will be woken from somewhere else. Poll::Pending } } } impl Default for LocalSet {...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
841
900
tokio-rs/tokio:tokio/src/task/local.rs:23
let local_queue = unsafe { // Safety: called from the thread that owns `LocalSet` self.context.shared.local_state.take_local_queue() }; for task in local_queue { drop(task); } // Take the queue from the Shared object to pre...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
}; if let Some(notified) = notified { self.shared.schedule(notified); } 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> {...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
} } impl Shared { /// Schedule the provided task on the scheduler. fn schedule(&self, task: task::Notified<Arc<Self>>) { CURRENT.with(|localdata| { match localdata.ctx.get() { Some(cx) if cx.shared.ptr_eq(self) => unsafe { // Safety: if the current `Local...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
} } }); } 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::Sch...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
unsafe { cx.shared.local_state.close_and_shutdown_all(); } } _ => unreachable!("runtime core not set in CURRENT thread-local"), }) } } } } } impl LocalState { unsafe fn task_pop_front(&self) -> Option<task::...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
63577cd8d3f2b1a1c787870125ab808eaa1eaa99
github
async-runtime
https://github.com/tokio-rs/tokio/blob/63577cd8d3f2b1a1c787870125ab808eaa1eaa99/tokio/src/task/local.rs
1,041
1,100