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:8
/// let unsend_data = unsend_data.clone(); /// task::spawn_local(async move { /// println!("{}", unsend_data); /// // ... /// }).await.unwrap(); /// }).await; /// } /// ``` #[track_caller] pub fn spawn_local<F>(future: F) -> JoinHan...
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
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
impl LocalSet { /// Returns a new local task set. pub fn new() -> LocalSet { LocalSet { tick: Cell::new(0), context: Context { owned: LocalOwnedTasks::new(), queue: VecDequeCell::with_capacity(INITIAL_CAPACITY), shared: Arc::new(Sha...
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
321
380
tokio-rs/tokio:tokio/src/task/local.rs:12
/// /// [`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(feature = "rt")] #[cfg_attr(docsrs, doc(cfg(feature = "rt")))] pub ...
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
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
/// [`spawn_local`]: fn@spawn_local /// [awaiting the local set]: #awaiting-a-localset pub async fn run_until<F>(&self, future: F) -> F::Output where F: Future, { let run_until = RunUntil { future, local_set: self, }; run_until.await } pub...
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
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
// // Safety: As spawned tasks are `!Send`, `run_unchecked` must be // used. We are responsible for maintaining the invariant that // `run_unchecked` is only called on threads that spawned the // task initially. Because `LocalSet` itself is `!Send`, and ...
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
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
task.map(|task| self.context.owned.assert_owner(task)) } fn with<T>(&self, f: impl FnOnce() -> T) -> T { CURRENT.set(&self.context, f) } } impl fmt::Debug for LocalSet { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("LocalSet").finish() } } impl Fut...
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
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
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 added. self.context.owned.close_and_shutdown_all(); ...
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
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
let future = crate::util::trace::task(future, "local", name, id.as_u64()); let (handle, notified) = self.owned.bind(future, self.shared.clone(), id); if let Some(notified) = notified { self.shared.schedule(notified); } handle } } // === impl LocalFuture === impl<T: F...
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
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
Poll::Pending }) } } impl Shared { /// Schedule the provided task on the scheduler. fn schedule(&self, task: task::Notified<Arc<Self>>) { CURRENT.with(|maybe_cx| match maybe_cx { Some(cx) if cx.shared.ptr_eq(self) => { cx.queue.push_back(task); } ...
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
681
725
tokio-rs/tokio:tokio/src/task/local.rs:13
/// [`spawn_local`]: fn@spawn_local /// [awaiting the local set]: #awaiting-a-localset pub async fn run_until<F>(&self, future: F) -> F::Output where F: Future, { let run_until = RunUntil { future, local_set: self, }; run_until.await } pub...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b1557ea5b2b0ea8d55b221e25fccb523bc1258ef
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b1557ea5b2b0ea8d55b221e25fccb523bc1258ef/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
// thread, the invariant is maintained. 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 t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b1557ea5b2b0ea8d55b221e25fccb523bc1258ef
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b1557ea5b2b0ea8d55b221e25fccb523bc1258ef/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
} } 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
b1557ea5b2b0ea8d55b221e25fccb523bc1258ef
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b1557ea5b2b0ea8d55b221e25fccb523bc1258ef/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
fn drop(&mut self) { self.with(|| { // Shut down all tasks in the LocalOwnedTasks and close it to // prevent new tasks from ever being added. self.context.owned.close_and_shutdown_all(); // We already called shutdown on all tasks above, so there is no ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b1557ea5b2b0ea8d55b221e25fccb523bc1258ef
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b1557ea5b2b0ea8d55b221e25fccb523bc1258ef/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
} handle } } // === impl LocalFuture === impl<T: Future> Future for RunUntil<'_, T> { type Output = T::Output; fn poll(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> { let me = self.project(); me.local_set.with(|| { me.local_set ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b1557ea5b2b0ea8d55b221e25fccb523bc1258ef
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b1557ea5b2b0ea8d55b221e25fccb523bc1258ef/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
/// Schedule the provided task on the scheduler. fn schedule(&self, task: task::Notified<Arc<Self>>) { CURRENT.with(|maybe_cx| match maybe_cx { Some(cx) if cx.shared.ptr_eq(self) => { cx.queue.push_back(task); } _ => { // First check whethe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b1557ea5b2b0ea8d55b221e25fccb523bc1258ef
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b1557ea5b2b0ea8d55b221e25fccb523bc1258ef/tokio/src/task/local.rs
681
719
tokio-rs/tokio:tokio/src/task/local.rs:8
/// let unsend_data = unsend_data.clone(); /// task::spawn_local(async move { /// println!("{}", unsend_data); /// // ... /// }).await.unwrap(); /// }).await; /// } /// ``` #[track_caller] pub fn spawn_local<F>(future: F) -> JoinHan...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1/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
1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
/// // we call `run_until` to drive the task set. /// local.spawn_local(async { /// // ... /// }); /// /// // Run the local task set. /// local.run_until(async move { /// // ... /// }).await; /// /// // When `run` finishes, we can spawn ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:13
/// background until the future passed to `run_until` completes. When the future /// 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. /// /// # Exa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:16
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 added. self.context.owned.close_and_shutdown_all(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
.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
1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
} } }); } 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| { let cx = maybe_cx.expect("scheduler context mi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1/tokio/src/task/local.rs
681
703
tokio-rs/tokio:tokio/src/task/local.rs:8
/// let unsend_data = unsend_data.clone(); /// task::spawn_local(async move { /// println!("{}", unsend_data); /// // ... /// }).await.unwrap(); /// }).await; /// } /// ``` #[track_caller] pub fn spawn_local<F>(future: F) -> JoinHan...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca51f6a98029e0bcaed063afa62896751adb3661
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca51f6a98029e0bcaed063afa62896751adb3661/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
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 { LocalSet { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca51f6a98029e0bcaed063afa62896751adb3661
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca51f6a98029e0bcaed063afa62896751adb3661/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
/// local.spawn_local(async { /// // ... /// }); /// /// // Run the local task set. /// local.run_until(async move { /// // ... /// }).await; /// /// // When `run` finishes, we can spawn _more_ futures, which will /// // run in subsequen...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca51f6a98029e0bcaed063afa62896751adb3661
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca51f6a98029e0bcaed063afa62896751adb3661/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:13
/// # Examples /// /// ```rust /// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// task::LocalSet::new().run_until(async { /// task::spawn_local(async move { /// // ... /// }).await.unwrap(); /// // ... /// })....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca51f6a98029e0bcaed063afa62896751adb3661
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca51f6a98029e0bcaed063afa62896751adb3661/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
// `spawn_local` spawns into the `LocalSet` on the current // thread, the invariant is maintained. 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 ag...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca51f6a98029e0bcaed063afa62896751adb3661
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca51f6a98029e0bcaed063afa62896751adb3661/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
CURRENT.set(&self.context, f) } } 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:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca51f6a98029e0bcaed063afa62896751adb3661
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca51f6a98029e0bcaed063afa62896751adb3661/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
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 added. self.context.owned.close_and_shutdown_all(); // We already called shutdown on all tasks abov...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca51f6a98029e0bcaed063afa62896751adb3661
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca51f6a98029e0bcaed063afa62896751adb3661/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
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.local_set.tick() { // If `tick` returns `true`, we nee...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca51f6a98029e0bcaed063afa62896751adb3661
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca51f6a98029e0bcaed063afa62896751adb3661/tokio/src/task/local.rs
641
698
tokio-rs/tokio:tokio/src/task/local.rs:18
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| { let cx = maybe_cx.expect("scheduler context missing"); assert!(cx.shared....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
ca51f6a98029e0bcaed063afa62896751adb3661
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ca51f6a98029e0bcaed063afa62896751adb3661/tokio/src/task/local.rs
681
698
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
cf3206842c0d94ecdaaeb421a58b1c963b627c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf3206842c0d94ecdaaeb421a58b1c963b627c3d/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
/// let unsend_data = unsend_data.clone(); /// task::spawn_local(async move { /// println!("{}", unsend_data); /// // ... /// }).await.unwrap(); /// }).await; /// } /// ``` #[track_caller] pub fn spawn_local<F>(future: F) -> JoinHan...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
cf3206842c0d94ecdaaeb421a58b1c963b627c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf3206842c0d94ecdaaeb421a58b1c963b627c3d/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
/// 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 { LocalSet { tick: Cell::new(0), conte...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
cf3206842c0d94ecdaaeb421a58b1c963b627c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf3206842c0d94ecdaaeb421a58b1c963b627c3d/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
/// }); /// /// // Run the local task set. /// local.run_until(async move { /// // ... /// }).await; /// /// // When `run` finishes, we can spawn _more_ futures, which will /// // run in subsequent calls to `run_until`. /// local.spawn_local(async ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
cf3206842c0d94ecdaaeb421a58b1c963b627c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf3206842c0d94ecdaaeb421a58b1c963b627c3d/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:13
/// ```rust /// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// task::LocalSet::new().run_until(async { /// task::spawn_local(async move { /// // ... /// }).await.unwrap(); /// // ... /// }).await; /// } /// ``...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
cf3206842c0d94ecdaaeb421a58b1c963b627c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf3206842c0d94ecdaaeb421a58b1c963b627c3d/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
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
cf3206842c0d94ecdaaeb421a58b1c963b627c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf3206842c0d94ecdaaeb421a58b1c963b627c3d/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
} 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 w...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
cf3206842c0d94ecdaaeb421a58b1c963b627c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf3206842c0d94ecdaaeb421a58b1c963b627c3d/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
self.with(|| { // Shut down all tasks in the LocalOwnedTasks and close it to // prevent new tasks from ever being added. self.context.owned.close_and_shutdown_all(); // We already called shutdown on all tasks above, so there is no // need to call shutdown. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
cf3206842c0d94ecdaaeb421a58b1c963b627c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf3206842c0d94ecdaaeb421a58b1c963b627c3d/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
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
cf3206842c0d94ecdaaeb421a58b1c963b627c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf3206842c0d94ecdaaeb421a58b1c963b627c3d/tokio/src/task/local.rs
641
696
tokio-rs/tokio:tokio/src/task/local.rs:18
} } impl task::Schedule for Arc<Shared> { fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("scheduler context missing"); assert!(cx.shared.ptr_eq(self)); cx.owned.remove(task) }) } fn schedul...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
cf3206842c0d94ecdaaeb421a58b1c963b627c3d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cf3206842c0d94ecdaaeb421a58b1c963b627c3d/tokio/src/task/local.rs
681
696
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
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
/// let unsend_data = unsend_data.clone(); /// task::spawn_local(async move { /// println!("{}", unsend_data); /// // ... /// }).await.unwrap(); /// }).await; /// } /// ``` #[cfg_attr(tokio_track_caller, track_caller)] pub fn spawn_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
/// 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 { LocalSet { tick: Cell::new(0), conte...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
/// }); /// /// // Run the local task set. /// local.run_until(async move { /// // ... /// }).await; /// /// // When `run` finishes, we can spawn _more_ futures, which will /// // run in subsequent calls to `run_until`. /// local.spawn_local(async ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
03969cdae7674681d1b10926e6a56fbb8908dbb8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03969cdae7674681d1b10926e6a56fbb8908dbb8/tokio/src/task/local.rs
361
420
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
b501f25202aba8f50c1ded4204f0129939fabc79
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/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
b501f25202aba8f50c1ded4204f0129939fabc79
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
/// let unsend_data = unsend_data.clone(); /// task::spawn_local(async move { /// println!("{}", unsend_data); /// // ... /// }).await.unwrap(); /// }).await; /// } /// ``` #[cfg_attr(tokio_track_caller, track_caller)] pub fn spawn_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b501f25202aba8f50c1ded4204f0129939fabc79
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
/// 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 { LocalSet { tick: Cell::new(0), contex...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b501f25202aba8f50c1ded4204f0129939fabc79
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:13
/// ```rust /// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// task::LocalSet::new().run_until(async { /// task::spawn_local(async move { /// // ... /// }).await.unwrap(); /// // ... /// }).await; /// } /// ``...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
b501f25202aba8f50c1ded4204f0129939fabc79
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:6
/// 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::block_on`]: method@crate::runtime::Runtime::block_on ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/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, } pin_project! { #[derive(Debug)] struct RunUntil<'a, F> { local_set: &'a LocalSet, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
/// let local = task::LocalSet::new(); /// /// // Run the local task set. /// local.run_until(async move { /// let unsend_data = unsend_data.clone(); /// task::spawn_local(async move { /// println!("{}", unsend_data); /// // ... /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/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
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
/// let local = task::LocalSet::new(); /// /// // Spawn a future on the local set. This future will be run when /// // we call `run_until` to drive the task set. /// local.spawn_local(async { /// // ... /// }); /// /// // Run the local task set. /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:13
/// /// 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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
fn tick(&self) -> bool { for _ in 0..MAX_TASKS_PER_TICK { match self.next_task() { // Run the task // // Safety: As spawned tasks are `!Send`, `run_unchecked` must be // used. We are responsible for maintaining the invariant that ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
.or_else(|| { self.context .shared .queue .lock() .as_mut() .and_then(|queue| queue.pop_front()) }) }; task.map(|task| self.context.tasks.borrow_mu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
// 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 { fn default() -> ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
// Take the queue from the Shared object to prevent pushing // notifications to it in the future. let queue = self.context.shared.queue.lock().take().unwrap(); for task in queue { drop(task); } assert!(self.context.tasks.borrow().owned.is_empt...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
Poll::Pending }) } } impl Shared { /// Schedule the provided task on the scheduler. fn schedule(&self, task: task::Notified<Arc<Self>>) { CURRENT.with(|maybe_cx| match maybe_cx { Some(cx) if cx.shared.ptr_eq(self) => { cx.tasks.borrow_mut().queue.push_back(task);...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8198ef38814c45f9dc02fcbf826225b5cf32a6bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8198ef38814c45f9dc02fcbf826225b5cf32a6bb/tokio/src/task/local.rs
681
726
tokio-rs/tokio:tokio/src/task/local.rs:18
Poll::Pending }) } } impl Shared { /// Schedule the provided task on the scheduler. fn schedule(&self, task: task::Notified<Arc<Self>>) { CURRENT.with(|maybe_cx| match maybe_cx { Some(cx) if cx.shared.ptr_eq(self) => { cx.tasks.borrow_mut().queue.push_back(task);...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f2a06bff1be147a72d40cb01d8bb621fbdc242fc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f2a06bff1be147a72d40cb01d8bb621fbdc242fc/tokio/src/task/local.rs
681
726
tokio-rs/tokio:tokio/src/task/local.rs:14
fn tick(&self) -> bool { for _ in 0..MAX_TASKS_PER_TICK { match self.next_task() { // Run the task // // Safety: As spawned tasks are `!Send`, `run_unchecked` must be // used. We are responsible for maintaining the invariant that ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
998dc5a2eb48bd0937b10bf0638b2f8346b5f9f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/998dc5a2eb48bd0937b10bf0638b2f8346b5f9f5/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
.or_else(|| { self.context .shared .queue .lock() .as_mut() .and_then(|queue| queue.pop_front()) }) } } fn with<T>(&self, f: impl FnOnce() -> T) ->...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
998dc5a2eb48bd0937b10bf0638b2f8346b5f9f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/998dc5a2eb48bd0937b10bf0638b2f8346b5f9f5/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
// since the remaining futures will be woken from somewhere else. Poll::Pending } } } impl Default for LocalSet { fn default() -> LocalSet { LocalSet::new() } } impl Drop for LocalSet { fn drop(&mut self) { self.with(|| { // Close the LocalOwnedTasks. Th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
998dc5a2eb48bd0937b10bf0638b2f8346b5f9f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/998dc5a2eb48bd0937b10bf0638b2f8346b5f9f5/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
for task in queue { task.shutdown(); } assert!(self.context.tasks.borrow().owned.is_empty()); }); } } // === impl LocalFuture === impl<T: Future> Future for RunUntil<'_, T> { type Output = T::Output; fn poll(self: Pin<&mut Self>, cx: &mut std::task::Contex...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
998dc5a2eb48bd0937b10bf0638b2f8346b5f9f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/998dc5a2eb48bd0937b10bf0638b2f8346b5f9f5/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
} impl Shared { /// Schedule the provided task on the scheduler. fn schedule(&self, task: task::Notified<Arc<Self>>) { CURRENT.with(|maybe_cx| match maybe_cx { Some(cx) if cx.shared.ptr_eq(self) => { cx.tasks.borrow_mut().queue.push_back(task); } _ =>...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
998dc5a2eb48bd0937b10bf0638b2f8346b5f9f5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/998dc5a2eb48bd0937b10bf0638b2f8346b5f9f5/tokio/src/task/local.rs
681
726
tokio-rs/tokio:tokio/src/task/local.rs:6
/// 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::block_on`]: method@crate::runtime::Runtime::block_on ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
2087f3e0ebb08d633d59c5f964b3901e68b3c038
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/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<VecDeque<task::Notified<Arc<Shared>>>>, /// Wake the `LocalSet` task waker: AtomicWaker, } pin_project! { #[derive(Debug)] struct RunUntil<'a, F> { local_set: &'a LocalSet, #[pin...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
2087f3e0ebb08d633d59c5f964b3901e68b3c038
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/tokio/src/task/local.rs
241
300
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
2087f3e0ebb08d633d59c5f964b3901e68b3c038
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:14
fn tick(&self) -> bool { for _ in 0..MAX_TASKS_PER_TICK { match self.next_task() { // Run the task // // Safety: As spawned tasks are `!Send`, `run_unchecked` must be // used. We are responsible for maintaining the invariant that ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
2087f3e0ebb08d633d59c5f964b3901e68b3c038
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
} } fn with<T>(&self, f: impl FnOnce() -> T) -> T { CURRENT.set(&self.context, f) } } 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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
2087f3e0ebb08d633d59c5f964b3901e68b3c038
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
LocalSet::new() } } impl Drop for LocalSet { fn drop(&mut self) { self.with(|| { // Close the LocalOwnedTasks. This ensures that any calls to // spawn_local in the destructor of a future on this LocalSet will // immediately cancel the task, and prevents the task from...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
2087f3e0ebb08d633d59c5f964b3901e68b3c038
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
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
2087f3e0ebb08d633d59c5f964b3901e68b3c038
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
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| { let cx = maybe_cx.expect("sch...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
2087f3e0ebb08d633d59c5f964b3901e68b3c038
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/tokio/src/task/local.rs
681
707
tokio-rs/tokio:tokio/src/task/local.rs:6
/// 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::block_on`]: method@crate::runtime::Runtime::block_on ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
549e89e9cd2073ffa70f1bd12022c5543343be78
github
async-runtime
https://github.com/tokio-rs/tokio/blob/549e89e9cd2073ffa70f1bd12022c5543343be78/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:8
/// let local = task::LocalSet::new(); /// /// // Run the local task set. /// local.run_until(async move { /// let unsend_data = unsend_data.clone(); /// task::spawn_local(async move { /// println!("{}", unsend_data); /// // ... /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
549e89e9cd2073ffa70f1bd12022c5543343be78
github
async-runtime
https://github.com/tokio-rs/tokio/blob/549e89e9cd2073ffa70f1bd12022c5543343be78/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
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 { LocalSet { t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
549e89e9cd2073ffa70f1bd12022c5543343be78
github
async-runtime
https://github.com/tokio-rs/tokio/blob/549e89e9cd2073ffa70f1bd12022c5543343be78/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:13
/// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// task::LocalSet::new().run_until(async { /// task::spawn_local(async move { /// // ... /// }).await.unwrap(); /// // ... /// }).await; /// } /// ``` /// //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
549e89e9cd2073ffa70f1bd12022c5543343be78
github
async-runtime
https://github.com/tokio-rs/tokio/blob/549e89e9cd2073ffa70f1bd12022c5543343be78/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
// 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, } } true } fn next_task(&self) -...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
549e89e9cd2073ffa70f1bd12022c5543343be78
github
async-runtime
https://github.com/tokio-rs/tokio/blob/549e89e9cd2073ffa70f1bd12022c5543343be78/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
} impl Future for LocalSet { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> { // Register the waker before starting to work self.context.shared.waker.register_by_ref(cx.waker()); if self.with(|| self.tick()) { // If `...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
549e89e9cd2073ffa70f1bd12022c5543343be78
github
async-runtime
https://github.com/tokio-rs/tokio/blob/549e89e9cd2073ffa70f1bd12022c5543343be78/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
None => break, }; // Safety: same as `run_unchecked`. task.shutdown(); } for task in self.context.tasks.borrow_mut().queue.drain(..) { task.shutdown(); } for task in self.context.shared.queue.lock().drain(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
549e89e9cd2073ffa70f1bd12022c5543343be78
github
async-runtime
https://github.com/tokio-rs/tokio/blob/549e89e9cd2073ffa70f1bd12022c5543343be78/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
} if me.local_set.tick() { // If `tick` returns `true`, we need to notify the local future again: // there are still tasks remaining in the run queue. cx.waker().wake_by_ref(); } Poll::Pending }) } } impl Shared { ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
549e89e9cd2073ffa70f1bd12022c5543343be78
github
async-runtime
https://github.com/tokio-rs/tokio/blob/549e89e9cd2073ffa70f1bd12022c5543343be78/tokio/src/task/local.rs
641
697
tokio-rs/tokio:tokio/src/task/local.rs:18
fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("scheduler context missing"); assert!(cx.shared.ptr_eq(self)); // safety: task must be contained by list. It is inserted into the // list in `bind`. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
549e89e9cd2073ffa70f1bd12022c5543343be78
github
async-runtime
https://github.com/tokio-rs/tokio/blob/549e89e9cd2073ffa70f1bd12022c5543343be78/tokio/src/task/local.rs
681
697
tokio-rs/tokio:tokio/src/task/local.rs:13
/// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// task::LocalSet::new().run_until(async { /// task::spawn_local(async move { /// // ... /// }).await.unwrap(); /// // ... /// }).await; /// } /// ``` /// //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6610ba9bd6b6a48d59f80573b5fa307972ace55a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6610ba9bd6b6a48d59f80573b5fa307972ace55a/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
// 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, } } true } fn next_task(&self) -...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6610ba9bd6b6a48d59f80573b5fa307972ace55a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6610ba9bd6b6a48d59f80573b5fa307972ace55a/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
} } impl Future for LocalSet { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> { // Register the waker before starting to work self.context.shared.waker.register_by_ref(cx.waker()); if self.with(|| self.tick()) { // If...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6610ba9bd6b6a48d59f80573b5fa307972ace55a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6610ba9bd6b6a48d59f80573b5fa307972ace55a/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
Some(task) => task, None => break, }; // Safety: same as `run_unchecked`. task.shutdown(); } for task in self.context.tasks.borrow_mut().queue.drain(..) { task.shutdown(); } for task in...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6610ba9bd6b6a48d59f80573b5fa307972ace55a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6610ba9bd6b6a48d59f80573b5fa307972ace55a/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
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
6610ba9bd6b6a48d59f80573b5fa307972ace55a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6610ba9bd6b6a48d59f80573b5fa307972ace55a/tokio/src/task/local.rs
641
698
tokio-rs/tokio:tokio/src/task/local.rs:18
} fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("scheduler context missing"); assert!(cx.shared.ptr_eq(self)); // safety: task must be contained by list. It is inserted into the // list in `b...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
6610ba9bd6b6a48d59f80573b5fa307972ace55a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6610ba9bd6b6a48d59f80573b5fa307972ace55a/tokio/src/task/local.rs
681
698
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
8fa29cb00a486c0ffc28f295c749573cb58a8967
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8fa29cb00a486c0ffc28f295c749573cb58a8967/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<VecDeque<task::Notified<Arc<Shared>>>>, /// Wake the `LocalSet` task waker: AtomicWaker, } pin_project! { #[derive(Debug)] struct RunUntil<'a, F> { local_set: &'a LocalSet, #[pin...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8fa29cb00a486c0ffc28f295c749573cb58a8967
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8fa29cb00a486c0ffc28f295c749573cb58a8967/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
/// /// let local = task::LocalSet::new(); /// /// // Run the local task set. /// local.run_until(async move { /// let unsend_data = unsend_data.clone(); /// task::spawn_local(async move { /// println!("{}", unsend_data); /// // ... ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8fa29cb00a486c0ffc28f295c749573cb58a8967
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8fa29cb00a486c0ffc28f295c749573cb58a8967/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
8fa29cb00a486c0ffc28f295c749573cb58a8967
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8fa29cb00a486c0ffc28f295c749573cb58a8967/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:13
/// ```rust /// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// task::LocalSet::new().run_until(async { /// task::spawn_local(async move { /// // ... /// }).await.unwrap(); /// // ... /// }).await; /// } /// ``...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8fa29cb00a486c0ffc28f295c749573cb58a8967
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8fa29cb00a486c0ffc28f295c749573cb58a8967/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
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
8fa29cb00a486c0ffc28f295c749573cb58a8967
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8fa29cb00a486c0ffc28f295c749573cb58a8967/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
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 waker before starting to work self.context.shared.waker.register_by_ref(cx.waker()); if sel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8fa29cb00a486c0ffc28f295c749573cb58a8967
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8fa29cb00a486c0ffc28f295c749573cb58a8967/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
let task = match self.context.tasks.borrow_mut().owned.pop_back() { Some(task) => task, None => break, }; // Safety: same as `run_unchecked`. task.shutdown(); } for task in self.context.tasks.borrow_mut().q...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8fa29cb00a486c0ffc28f295c749573cb58a8967
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8fa29cb00a486c0ffc28f295c749573cb58a8967/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
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
8fa29cb00a486c0ffc28f295c749573cb58a8967
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8fa29cb00a486c0ffc28f295c749573cb58a8967/tokio/src/task/local.rs
641
700
tokio-rs/tokio:tokio/src/task/local.rs:18
}) } fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { use std::ptr::NonNull; CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("scheduler context missing"); assert!(cx.shared.ptr_eq(self)); let ptr = NonNull::from(task.header()); /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8fa29cb00a486c0ffc28f295c749573cb58a8967
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8fa29cb00a486c0ffc28f295c749573cb58a8967/tokio/src/task/local.rs
681
702