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:23
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().wake_by_ref(); } Poll::Pending ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f8097437dde60e9478e3f38302ac28bf5bc3f3f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f8097437dde60e9478e3f38302ac28bf5bc3f3f5/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
// We are on the thread that owns the `LocalSet`, so we can // wake to the local queue. _ if localdata.get_or_insert_id() == self.owner => { unsafe { // Safety: we just checked that the thread ID matches // the localset'...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f8097437dde60e9478e3f38302ac28bf5bc3f3f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f8097437dde60e9478e3f38302ac28bf5bc3f3f5/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
impl task::Schedule for Arc<Shared> { fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { CURRENT.with(|LocalData { ctx, .. }| match ctx.get() { None => panic!("scheduler context missing"), Some(cx) => { assert!(cx.shared.ptr_eq(self)); cx.own...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f8097437dde60e9478e3f38302ac28bf5bc3f3f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f8097437dde60e9478e3f38302ac28bf5bc3f3f5/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
impl LocalData { fn get_or_insert_id(&self) -> ThreadId { self.thread_id.get().unwrap_or_else(|| { let id = thread::current().id(); self.thread_id.set(Some(id)); id }) } } fn thread_id() -> Option<ThreadId> { CURRENT .try_with(|localdata| localdat...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f8097437dde60e9478e3f38302ac28bf5bc3f3f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f8097437dde60e9478e3f38302ac28bf5bc3f3f5/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
// 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
f8097437dde60e9478e3f38302ac28bf5bc3f3f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f8097437dde60e9478e3f38302ac28bf5bc3f3f5/tokio/src/task/local.rs
1,041
1,085
tokio-rs/tokio:tokio/src/task/local.rs:7
struct Shared { /// Local run queue sender and receiver. /// /// # Safety /// /// This field must *only* be accessed from the thread that owns the /// `LocalSet` (i.e., `Thread::current().id() == owner`). local_queue: VecDequeCell<task::Notified<Arc<Shared>>>, /// The `ThreadId` of the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
#[cfg(not(any(loom, tokio_no_const_thread_local)))] tokio_thread_local!(static CURRENT: LocalData = const { LocalData { thread_id: Cell::new(None), ctx: RcCell::new(), } }); struct LocalData { thread_id: Cell<Option<ThreadId>>, ctx: RcCell<Context>, } cfg_rt! { /// Spawns a `!Send` future on the l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
/// }).await; /// } /// ``` #[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_caller] pub(super) fn spawn_local_inner<F>(future: F, name: O...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
ctx.set(self.0.take()); }) } } 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 { LocalSet { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:14
} /// 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
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
pub(in crate::task) fn spawn_named<F>( &self, 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 `L...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
Some(task) => crate::coop::budget(|| task.run()), // We have fully drained the queue of notified tasks, so the // local future doesn't need to be notified again — it can wait // until something else wakes a task in the local set. None => return false, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
// on the same thread if we have access to the `LocalSet`, and can // therefore access the local run queue. self.context.shared.local_queue().pop_front() } } fn with<T>(&self, f: impl FnOnce() -> T) -> T { CURRENT.with(|LocalData { ctx, .. }| { struct Reset<'...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
self.ctx_ref.replace(self.val.take()); } } let old = ctx.replace(Some(self.context.clone())); let _reset = Reset { ctx_ref: ctx, val: old, }; (f.take().unwrap())() }); match res { O...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
/// # Panics /// /// This method panics if called after the `LocalSet` has started /// running. /// /// # Unstable /// /// This option is currently unstable and its implementation is /// incomplete. The API may change or be removed in the future. See ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:20
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(&mut ctx.shared)) .expect("Unhandled Panic behavior modified after start...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
impl Default for LocalSet { fn default() -> LocalSet { 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. s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:22
assert!(self.context.owned.is_empty()); }); } } // === impl Context === impl Context { #[track_caller] fn spawn<F>(&self, future: F, name: Option<&str>) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { let id = crate::runtime::task::Id::next...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
841
900
tokio-rs/tokio:tokio/src/task/local.rs:23
.waker .register_by_ref(cx.waker()); let _no_blocking = crate::runtime::enter::disallow_blocking(); let f = me.future; if let Poll::Ready(output) = crate::coop::budget(|| f.poll(cx)) { return Poll::Ready(output); } if me.loca...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
match localdata.ctx.get() { Some(cx) if cx.shared.ptr_eq(self) => unsafe { // Safety: if the current `LocalSet` context points to this // `LocalSet`, then we are on the thread that owns it. cx.shared.local_queue().push_back(task); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
921
980
tokio-rs/tokio:tokio/src/task/local.rs:25
} } // 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>> { CURRENT.with(|LocalData...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
961
1,020
tokio-rs/tokio:tokio/src/task/local.rs:26
}) } } } } } impl LocalData { fn get_or_insert_id(&self) -> ThreadId { self.thread_id.get().unwrap_or_else(|| { let id = thread::current().id(); self.thread_id.set(Some(id)); id }) } } fn thread_id() -> Option<ThreadId...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
1,001
1,060
tokio-rs/tokio:tokio/src/task/local.rs:27
}; crate::runtime::Builder::new_current_thread() .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. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
1,041
1,092
tokio-rs/tokio:tokio/src/task/local.rs:28
notify.notify_one(); let task = unsafe { local.context.shared.local_queue().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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
964535eab006ef7b776e644e53076493a931fbce
github
async-runtime
https://github.com/tokio-rs/tokio/blob/964535eab006ef7b776e644e53076493a931fbce/tokio/src/task/local.rs
1,081
1,092
tokio-rs/tokio:tokio/src/task/local.rs:7
struct Shared { /// Local run queue sender and receiver. /// /// # Safety /// /// This field must *only* be accessed from the thread that owns the /// `LocalSet` (i.e., `Thread::current().id() == owner`). local_queue: VecDequeCell<task::Notified<Arc<Shared>>>, /// The `ThreadId` of the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
23a1ccf24fddb78abf5169053368c8b7fd6733dc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/23a1ccf24fddb78abf5169053368c8b7fd6733dc/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
#[cfg(not(any(loom, tokio_no_const_thread_local)))] thread_local!(static CURRENT: LocalData = const { LocalData { thread_id: Cell::new(None), ctx: RcCell::new(), } }); struct LocalData { thread_id: Cell<Option<ThreadId>>, ctx: RcCell<Context>, } cfg_rt! { /// Spawns a `!Send` future on the local t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
23a1ccf24fddb78abf5169053368c8b7fd6733dc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/23a1ccf24fddb78abf5169053368c8b7fd6733dc/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:1
//! Runs `!Send` futures on the current thread. use crate::loom::sync::{Arc, Mutex}; use crate::runtime::task::{self, JoinHandle, LocalOwnedTasks, Task}; use crate::sync::AtomicWaker; use crate::util::{RcCell, VecDequeCell}; use std::cell::Cell; use std::collections::VecDeque; use std::fmt; use std::future::Future; us...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
1
60
tokio-rs/tokio:tokio/src/task/local.rs:6
/// /// let (send, response) = oneshot::channel(); /// spawner.spawn(Task::AddOne(10, send)); /// let eleven = response.await.unwrap(); /// assert_eq!(eleven, 11); /// } /// ``` /// /// [`Send`]: trait@std::marker::Send /// [local task set]: struct@LocalSet /// [`...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:7
/// LocalSet state shared between threads. struct Shared { /// Remote run queue sender. queue: Mutex<Option<VecDeque<task::Notified<Arc<Shared>>>>>, /// Wake the `LocalSet` task. waker: AtomicWaker, /// How to respond to unhandled task panics. #[cfg(tokio_unstable)] pub(crate) unhandled_pa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
/// /// ```rust /// use std::rc::Rc; /// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// let unsend_data = Rc::new("my unsend data..."); /// /// let local = task::LocalSet::new(); /// /// // Run the local task set. /// local.run_until(asy...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
} } /// 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(Option<Rc<Context>>); im...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
#[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
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:13
/// }); /// 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_c...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
/// // ... /// }).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, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
/// 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
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
} else { self.context.queue.pop_front().or_else(|| { self.context .shared .queue .lock() .as_mut() .and_then(|queue| queue.pop_front()) }) }; task.map(|task| self....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
let res = CURRENT.try_with(|ctx| { struct Reset<'a> { ctx_ref: &'a RcCell<Context>, val: Option<Rc<Context>>, } impl<'a> Drop for Reset<'a> { fn drop(&mut self) { self.ctx_ref.replace(self.val.take()); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:19
/// // 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
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:20
} 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
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
// === impl Context === impl Context { #[track_caller] fn spawn<F>(&self, future: F, name: Option<&str>) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { let id = crate::runtime::task::Id::next(); let future = crate::util::trace::task(future, "lo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:22
if let Poll::Ready(output) = crate::coop::budget(|| 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. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
841
900
tokio-rs/tokio:tokio/src/task/local.rs:23
std::ptr::eq(self, other) } } impl task::Schedule for Arc<Shared> { fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { CURRENT.with(|maybe_cx| match maybe_cx.get() { None => panic!("scheduler context missing"), Some(cx) => { assert!(cx.shared.ptr_eq(sel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
881
940
tokio-rs/tokio:tokio/src/task/local.rs:24
} } } #[cfg(test)] mod tests { use super::*; #[test] fn local_current_thread_scheduler() { let f = async { LocalSet::new() .run_until(async { spawn_local(async {}).await.unwrap(); }) .await; }; crate...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca9dd726b1c00736faa72df1885831545306a0a5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca9dd726b1c00736faa72df1885831545306a0a5/tokio/src/task/local.rs
921
942
tokio-rs/tokio:tokio/src/task/local.rs:23
std::ptr::eq(self, other) } } impl task::Schedule for Arc<Shared> { fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { CURRENT.with(|maybe_cx| match maybe_cx.get() { None => panic!("scheduler context missing"), Some(cx) => { assert!(cx.shared.ptr_eq(sel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
7096a8007502526b23ee1707a6cb37c68c4f0a84
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7096a8007502526b23ee1707a6cb37c68c4f0a84/tokio/src/task/local.rs
881
923
tokio-rs/tokio:tokio/src/task/local.rs:1
//! Runs `!Send` futures on the current thread. use crate::loom::sync::{Arc, Mutex}; use crate::runtime::task::{self, JoinHandle, LocalOwnedTasks, Task}; use crate::sync::AtomicWaker; use crate::util::VecDequeCell; use std::cell::Cell; use std::collections::VecDeque; use std::fmt; use std::future::Future; use std::mar...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/src/task/local.rs
1
60
tokio-rs/tokio:tokio/src/task/local.rs:7
/// LocalSet state shared between threads. struct Shared { /// Remote run queue sender. queue: Mutex<Option<VecDeque<task::Notified<Arc<Shared>>>>>, /// Wake the `LocalSet` task. waker: AtomicWaker, /// How to respond to unhandled task panics. #[cfg(tokio_unstable)] pub(crate) unhandled_pa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
/// /// #[tokio::main] /// async fn main() { /// let unsend_data = Rc::new("my unsend data..."); /// /// let local = task::LocalSet::new(); /// /// // Run the local task set. /// local.run_until(async move { /// let unsend_data = unsend_data.clone(); /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
} } /// 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(Option<Rc<Context>>); im...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:15
/// 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
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
} else { self.context.queue.pop_front().or_else(|| { self.context .shared .queue .lock() .as_mut() .and_then(|queue| queue.pop_front()) }) }; task.map(|task| self....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
let res = CURRENT.try_with(|ctx| { struct Reset<'a> { ctx_ref: &'a Cell<Option<Rc<Context>>>, val: Option<Rc<Context>>, } impl<'a> Drop for Reset<'a> { fn drop(&mut self) { self.ctx_ref.replace(self.val.take()); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:21
// === impl Context === impl Context { #[track_caller] fn spawn<F>(&self, future: F, name: Option<&str>) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { let id = crate::runtime::task::Id::next(); let future = crate::util::trace::task(future, "lo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:22
if let Poll::Ready(output) = crate::coop::budget(|| 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. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/src/task/local.rs
841
900
tokio-rs/tokio:tokio/src/task/local.rs:23
self.waker.wake(); } } } }); } fn ptr_eq(&self, other: &Shared) -> bool { std::ptr::eq(self, other) } } impl task::Schedule for Arc<Shared> { fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { CURRENT.with(|maybe_cx| { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/src/task/local.rs
881
936
tokio-rs/tokio:tokio/src/task/local.rs:24
// `CURRENT` should match with `&self`, i.e. there is no // opportunity for a nested scheduler to be called. CURRENT.with(|maybe_cx| { let ctx = clone_rc(maybe_cx); match ctx { Some(cx) if Arc::ptr_eq(self, &...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e4cbc70279f8ee81c7ce7b57edf8a56844da1f39
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4cbc70279f8ee81c7ce7b57edf8a56844da1f39/tokio/src/task/local.rs
921
936
tokio-rs/tokio:tokio/src/task/local.rs:8
/// /// ```rust /// use std::rc::Rc; /// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// let unsend_data = Rc::new("my unsend data..."); /// /// let local = task::LocalSet::new(); /// /// // Run the local task set. /// local.run_until(asy...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
} }) } } /// 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(Option<R...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
queue: Mutex::new(Some(VecDeque::with_capacity(INITIAL_CAPACITY))), waker: AtomicWaker::new(), #[cfg(tokio_unstable)] unhandled_panic: crate::runtime::UnhandledPanic::Ignore, }), unhandled_panic: Cell::new(false), })...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:13
/// }).await; /// // ... /// }); /// 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_blockin...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
/// // ... /// }).await.unwrap(); /// // ... /// }).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, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
/// Ticks the scheduler, returning whether the local future needs to be /// notified again. fn tick(&self) -> bool { for _ in 0..MAX_TASKS_PER_TICK { // Make sure we didn't hit an unhandled panic if self.context.unhandled_panic.get() { panic!("a spawned task panic...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
.and_then(|queue| queue.pop_front()) .or_else(|| self.context.queue.pop_front()) } else { self.context.queue.pop_front().or_else(|| { self.context .shared .queue .lock() .as_mut() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:18
/// /// # #[tokio::main] /// # async fn main() { /// tokio::task::LocalSet::new() /// .unhandled_panic(UnhandledPanic::ShutdownRuntime) /// .run_until(async { /// tokio::task::spawn_local(async { panic!("boom"); }); /// tokio::task::spawn_l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
// Register the waker before starting to work self.context.shared.waker.register_by_ref(cx.waker()); if self.with(|| self.tick()) { // If `tick` returns true, we need to notify the local future again: // there are still tasks remaining in the run queue. cx.waker().wa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:20
// notifications to it in the future. let queue = self.context.shared.queue.lock().take().unwrap(); for task in queue { drop(task); } assert!(self.context.owned.is_empty()); }); } } // === impl Context === impl Context { #[track_caller] ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
me.local_set.with(|| { me.local_set .context .shared .waker .register_by_ref(cx.waker()); let _no_blocking = crate::runtime::enter::disallow_blocking(); let f = me.future; if let Poll::Ready(output) = crate...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:22
if let Some(queue) = lock.as_mut() { queue.push_back(task); drop(lock); self.waker.wake(); } } } }); } fn ptr_eq(&self, other: &Shared) -> bool { std::ptr::eq(self, other) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
841
894
tokio-rs/tokio:tokio/src/task/local.rs:23
// `CURRENT` should match with `&self`, i.e. there is no // opportunity for a nested scheduler to be called. CURRENT.with(|maybe_cx| match maybe_cx.get() { Some(cx) if Arc::ptr_eq(self, &cx.shared) => { cx.unhandled_panic.set(tr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
116fa7c61470081717357674e868c47dd606e177
github
async-runtime
https://github.com/tokio-rs/tokio/blob/116fa7c61470081717357674e868c47dd606e177/tokio/src/task/local.rs
881
894
tokio-rs/tokio:tokio/src/task/local.rs:16
} else { self.context.queue.pop_front().or_else(|| { self.context .shared .queue .lock() .as_mut() .and_then(|queue| queue.pop_front()) }) }; task.map(|task| self....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:18
/// # async fn main() { /// tokio::task::LocalSet::new() /// .unhandled_panic(UnhandledPanic::ShutdownRuntime) /// .run_until(async { /// tokio::task::spawn_local(async { panic!("boom"); }); /// tokio::task::spawn_local(async { /// // T...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
if self.with(|| self.tick()) { // If `tick` returns true, we need to notify the local future again: // there are still tasks remaining in the run queue. cx.waker().wake_by_ref(); Poll::Pending } else if self.context.owned.is_empty() { // If the schedul...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:20
for task in queue { drop(task); } assert!(self.context.owned.is_empty()); }); } } // === impl Context === impl Context { #[track_caller] fn spawn<F>(&self, future: F, name: Option<&str>) -> JoinHandle<F::Output> where F: Future + 'static, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
me.local_set .context .shared .waker .register_by_ref(cx.waker()); let _no_blocking = crate::runtime::enter::disallow_blocking(); let f = me.future; if let Poll::Ready(output) = crate::coop::budget(|| f.poll(cx)) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:22
_ => { // 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() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/task/local.rs
841
900
tokio-rs/tokio:tokio/src/task/local.rs:23
fn unhandled_panic(&self) { use crate::runtime::UnhandledPanic; match self.unhandled_panic { UnhandledPanic::Ignore => { // Do nothing } UnhandledPanic::ShutdownRuntime => { // This hook is only called from ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/src/task/local.rs
881
905
tokio-rs/tokio:tokio/src/task/local.rs:16
} else { self.context.queue.pop_front().or_else(|| { self.context .shared .queue .lock() .as_mut() .and_then(|queue| queue.pop_front()) }) }; task.map(|task| self....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
5288e1e144d33ace0070325b16029523b1db0ffe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5288e1e144d33ace0070325b16029523b1db0ffe/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:13
/// }); /// 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 #[cfg(fea...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
/// }).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
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
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
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
self.context.queue.pop_front().or_else(|| { self.context .shared .queue .lock() .as_mut() .and_then(|queue| queue.pop_front()) }) }; task.map(|task| self.context.owned.assert_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:18
/// tokio::task::LocalSet::new() /// .unhandled_panic(UnhandledPanic::ShutdownRuntime) /// .run_until(async { /// tokio::task::spawn_local(async { panic!("boom"); }); /// tokio::task::spawn_local(async { /// // This task never completes ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:20
drop(task); } assert!(self.context.owned.is_empty()); }); } } // === impl Context === impl Context { #[track_caller] fn spawn<F>(&self, future: F, name: Option<&str>) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
.context .shared .waker .register_by_ref(cx.waker()); let _no_blocking = crate::runtime::enter::disallow_blocking(); let f = me.future; if let Poll::Ready(output) = crate::coop::budget(|| f.poll(cx)) { return Poll::Rea...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/src/task/local.rs
801
860
tokio-rs/tokio:tokio/src/task/local.rs:22
// 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.pu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/src/task/local.rs
841
900
tokio-rs/tokio:tokio/src/task/local.rs:23
use crate::runtime::UnhandledPanic; match self.unhandled_panic { UnhandledPanic::Ignore => { // Do nothing } UnhandledPanic::ShutdownRuntime => { // This hook is only called from within the runtime, so ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
14fca343d58207f20cc23d7867cfa7a9b0b26576
github
async-runtime
https://github.com/tokio-rs/tokio/blob/14fca343d58207f20cc23d7867cfa7a9b0b26576/tokio/src/task/local.rs
881
904
tokio-rs/tokio:tokio/src/task/local.rs:6
/// let (send, response) = oneshot::channel(); /// spawner.spawn(Task::AddOne(10, send)); /// let eleven = response.await.unwrap(); /// assert_eq!(eleven, 11); /// } /// ``` /// /// [`Send`]: trait@std::marker::Send /// [local task set]: struct@LocalSet /// [`Runtime:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:7
/// LocalSet state shared between threads. struct Shared { /// Remote run queue sender. queue: Mutex<Option<VecDeque<task::Notified<Arc<Shared>>>>>, /// Wake the `LocalSet` task. waker: AtomicWaker, /// How to respond to unhandled task panics. #[cfg(tokio_unstable)] pub(crate) unhandled_pa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
/// #[tokio::main] /// async fn main() { /// let unsend_data = Rc::new("my unsend data..."); /// /// let local = task::LocalSet::new(); /// /// // Run the local task set. /// local.run_until(async move { /// let unsend_data = unsend_data.clone(); /// t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
/// 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; impl LocalSet { /// Returns a new local task set. pub fn new() -> LocalSet { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:12
/// let local = task::LocalSet::new(); /// local.block_on(&rt, async { /// let join = task::spawn_local(async { /// let blocking_result = task::spawn_blocking(|| { /// // ... /// }).await; /// // ... /// }); /// join.await.unwrap(); ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
/// #[tokio::main] /// async fn main() { /// task::LocalSet::new().run_until(async { /// task::spawn_local(async move { /// // ... /// }).await.unwrap(); /// // ... /// }).await; /// } /// ``` /// /// [`spawn_local`]: fn@spawn_local...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
// in that case, the `LocalSet` must already be awake. self.context.shared.waker.wake(); handle } /// Ticks the scheduler, returning whether the local future needs to be /// notified again. fn tick(&self) -> bool { for _ in 0..MAX_TASKS_PER_TICK { // Make sure we did...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
.shared .queue .lock() .as_mut() .and_then(|queue| queue.pop_front()) .or_else(|| self.context.queue.pop_front()) } else { self.context.queue.pop_front().or_else(|| { self.context .sha...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:17
/// .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 Arc::get_mut(&mut self.context.shared...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
Poll::Pending } } } impl Default for LocalSet { fn default() -> LocalSet { LocalSet::new() } } impl Drop for LocalSet { fn drop(&mut self) { self.with(|| { // Shut down all tasks in the LocalOwnedTasks and close it to // prevent new tasks from ever being...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
681
740
tokio-rs/tokio:tokio/src/task/local.rs:19
fn spawn<F>(&self, future: F, name: Option<&str>) -> JoinHandle<F::Output> where F: Future + 'static, F::Output: 'static, { let id = crate::runtime::task::Id::next(); let future = crate::util::trace::task(future, "local", name, id.as_u64()); let (handle, notified) = self...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
721
780
tokio-rs/tokio:tokio/src/task/local.rs:20
if me.local_set.tick() { // If `tick` returns `true`, we need to notify the local future again: // there are still tasks remaining in the run queue. cx.waker().wake_by_ref(); } Poll::Pending }) } } impl Shared { /// Schedule the p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
761
820
tokio-rs/tokio:tokio/src/task/local.rs:21
CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("scheduler context missing"); assert!(cx.shared.ptr_eq(self)); cx.owned.remove(task) }) } fn schedule(&self, task: task::Notified<Self>) { Shared::schedule(self, task); } cfg_unstable! { fn u...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c98be229ff3a4e1e230711844b7e38a30cb64f2c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c98be229ff3a4e1e230711844b7e38a30cb64f2c/tokio/src/task/local.rs
801
835
tokio-rs/tokio:tokio/src/task/local.rs:6
/// let (send, response) = oneshot::channel(); /// spawner.spawn(Task::AddOne(10, send)); /// let eleven = response.await.unwrap(); /// assert_eq!(eleven, 11); /// } /// ``` /// /// [`Send`]: trait@std::marker::Send /// [local task set]: struct@LocalSet /// [`Runtime:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
2bad98f879811760922818807157b173e58625d1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bad98f879811760922818807157b173e58625d1/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:7
/// Wake the `LocalSet` task. waker: AtomicWaker, } pin_project! { #[derive(Debug)] struct RunUntil<'a, F> { local_set: &'a LocalSet, #[pin] future: F, } } scoped_thread_local!(static CURRENT: Context); cfg_rt! { /// Spawns a `!Send` future on the local task set. /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
2bad98f879811760922818807157b173e58625d1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2bad98f879811760922818807157b173e58625d1/tokio/src/task/local.rs
241
300