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: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
bcb95db4e2d4a9a43a3f3f5e129ddb7232599451
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bcb95db4e2d4a9a43a3f3f5e129ddb7232599451/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
bcb95db4e2d4a9a43a3f3f5e129ddb7232599451
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bcb95db4e2d4a9a43a3f3f5e129ddb7232599451/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
const REMOTE_FIRST_INTERVAL: u8 = 31; impl LocalSet { /// Returns a new local task set. pub fn new() -> LocalSet { LocalSet { tick: Cell::new(0), context: Context { tasks: RefCell::new(Tasks { owned: LinkedList::new(), queu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
bcb95db4e2d4a9a43a3f3f5e129ddb7232599451
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bcb95db4e2d4a9a43a3f3f5e129ddb7232599451/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:12
/// // ... /// }).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_pl...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
bcb95db4e2d4a9a43a3f3f5e129ddb7232599451
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bcb95db4e2d4a9a43a3f3f5e129ddb7232599451/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
/// // ... /// }).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
bcb95db4e2d4a9a43a3f3f5e129ddb7232599451
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bcb95db4e2d4a9a43a3f3f5e129ddb7232599451/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
true } fn next_task(&self) -> Option<task::Notified<Arc<Shared>>> { let tick = self.tick.get(); self.tick.set(tick.wrapping_add(1)); if tick % REMOTE_FIRST_INTERVAL == 0 { self.context .shared .queue .lock() .u...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
bcb95db4e2d4a9a43a3f3f5e129ddb7232599451
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bcb95db4e2d4a9a43a3f3f5e129ddb7232599451/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
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 `tick` returns true, we need to notify the local future ag...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
bcb95db4e2d4a9a43a3f3f5e129ddb7232599451
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bcb95db4e2d4a9a43a3f3f5e129ddb7232599451/tokio/src/task/local.rs
561
620
tokio-rs/tokio:tokio/src/task/local.rs:16
} for task in self.context.tasks.borrow_mut().queue.drain(..) { task.shutdown(); } for task in self.context.shared.queue.lock().unwrap().drain(..) { task.shutdown(); } assert!(self.context.tasks.borrow().owned.is_empty()); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
bcb95db4e2d4a9a43a3f3f5e129ddb7232599451
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bcb95db4e2d4a9a43a3f3f5e129ddb7232599451/tokio/src/task/local.rs
601
660
tokio-rs/tokio:tokio/src/task/local.rs:17
cx.waker().wake_by_ref(); } Poll::Pending }) } } impl Shared { /// Schedule the provided task on the scheduler. fn schedule(&self, task: task::Notified<Arc<Self>>) { CURRENT.with(|maybe_cx| match maybe_cx { Some(cx) if cx.shared.ptr_eq(self) => { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
bcb95db4e2d4a9a43a3f3f5e129ddb7232599451
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bcb95db4e2d4a9a43a3f3f5e129ddb7232599451/tokio/src/task/local.rs
641
695
tokio-rs/tokio:tokio/src/task/local.rs:18
let cx = maybe_cx.expect("scheduler context missing"); assert!(cx.shared.ptr_eq(self)); let ptr = NonNull::from(task.header()); // safety: task must be contained by list. It is inserted into the // list in `bind`. unsafe { cx.tasks.borrow_mut().owned.remove(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
bcb95db4e2d4a9a43a3f3f5e129ddb7232599451
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bcb95db4e2d4a9a43a3f3f5e129ddb7232599451/tokio/src/task/local.rs
681
695
tokio-rs/tokio:tokio/src/task/local.rs:17
cx.waker().wake_by_ref(); } Poll::Pending }) } } impl Shared { /// Schedule the provided task on the scheduler. fn schedule(&self, task: task::Notified<Arc<Self>>) { CURRENT.with(|maybe_cx| match maybe_cx { Some(cx) if cx.shared.ptr_eq(self) => { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c6f08120d0e8764f5ff4d474ded342c85d9b188d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6f08120d0e8764f5ff4d474ded342c85d9b188d/tokio/src/task/local.rs
641
695
tokio-rs/tokio:tokio/src/task/local.rs:3
/// /// ```rust /// use tokio::{task, time}; /// use std::rc::Rc; /// /// #[tokio::main] /// async fn main() { /// let unsend_data = Rc::new("world"); /// let local = task::LocalSet::new(); /// /// let unsend_data2 = unsend_data.clone(); /// local.spawn_local(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
22c27b9282da399574bf9d58461fe0f1869be894
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22c27b9282da399574bf9d58461fe0f1869be894/tokio/src/task/local.rs
81
140
tokio-rs/tokio:tokio/src/task/local.rs:4
} } /// State available from the thread-local struct Context { /// Owned task set and local run queue tasks: RefCell<Tasks>, /// State shared between threads. shared: Arc<Shared>, } struct Tasks { /// Collection of all active tasks spawned onto this executor. owned: LinkedList<Task<Arc<Shared...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
22c27b9282da399574bf9d58461fe0f1869be894
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22c27b9282da399574bf9d58461fe0f1869be894/tokio/src/task/local.rs
121
180
tokio-rs/tokio:tokio/src/task/local.rs:5
cfg_rt! { /// Spawns a `!Send` future on the local task set. /// /// The spawned future will be run on the same thread that called `spawn_local.` /// This may only be called from the context of a local task set. /// /// # Panics /// /// - This function panics if called outside of a local...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
22c27b9282da399574bf9d58461fe0f1869be894
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22c27b9282da399574bf9d58461fe0f1869be894/tokio/src/task/local.rs
161
220
tokio-rs/tokio:tokio/src/task/local.rs:6
let cx = maybe_cx .expect("`spawn_local` called from outside of a `task::LocalSet`"); // Safety: Tasks are only polled and dropped from the thread that // spawns them. let (task, handle) = unsafe { task::joinable_local(future) }; cx.tasks.borrow_mut().que...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
22c27b9282da399574bf9d58461fe0f1869be894
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22c27b9282da399574bf9d58461fe0f1869be894/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:10
/// Run 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 /// back...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
22c27b9282da399574bf9d58461fe0f1869be894
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22c27b9282da399574bf9d58461fe0f1869be894/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
/// notified again. 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 t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
22c27b9282da399574bf9d58461fe0f1869be894
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22c27b9282da399574bf9d58461fe0f1869be894/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
.pop_front() .or_else(|| self.context.shared.queue.lock().unwrap().pop_front()) } } 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....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
22c27b9282da399574bf9d58461fe0f1869be894
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22c27b9282da399574bf9d58461fe0f1869be894/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
impl Default for LocalSet { fn default() -> LocalSet { LocalSet::new() } } impl Drop for LocalSet { fn drop(&mut self) { self.with(|| { // Loop required here to ensure borrow is dropped between iterations #[allow(clippy::while_let_loop)] loop { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
22c27b9282da399574bf9d58461fe0f1869be894
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22c27b9282da399574bf9d58461fe0f1869be894/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
let me = self.project(); 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; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
22c27b9282da399574bf9d58461fe0f1869be894
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22c27b9282da399574bf9d58461fe0f1869be894/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
fn ptr_eq(&self, other: &Shared) -> bool { self as *const _ == other as *const _ } } impl task::Schedule for Arc<Shared> { fn bind(task: Task<Self>) -> Arc<Shared> { CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("scheduler context missing"); cx.tasks.borrow_mut().ow...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
22c27b9282da399574bf9d58461fe0f1869be894
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22c27b9282da399574bf9d58461fe0f1869be894/tokio/src/task/local.rs
561
594
tokio-rs/tokio:tokio/src/task/local.rs:11
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
fede3db76aef95c010c3e0c3da3b732380285097
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fede3db76aef95c010c3e0c3da3b732380285097/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
.or_else(|| self.context.shared.queue.lock().unwrap().pop_front()) } } 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").fini...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
fede3db76aef95c010c3e0c3da3b732380285097
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fede3db76aef95c010c3e0c3da3b732380285097/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
fn default() -> LocalSet { LocalSet::new() } } impl Drop for LocalSet { fn drop(&mut self) { self.with(|| { // Loop required here to ensure borrow is dropped between iterations #[allow(clippy::while_let_loop)] loop { let task = match self.cont...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
fede3db76aef95c010c3e0c3da3b732380285097
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fede3db76aef95c010c3e0c3da3b732380285097/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
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
fede3db76aef95c010c3e0c3da3b732380285097
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fede3db76aef95c010c3e0c3da3b732380285097/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:5
cfg_rt! { /// Spawns a `!Send` future on the local task set. /// /// The spawned future will be run on the same thread that called `spawn_local.` /// This may only be called from the context of a local task set. /// /// # Panics /// /// - This function panics if called outside of a local...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/task/local.rs
161
220
tokio-rs/tokio:tokio/src/task/local.rs:6
.expect("`spawn_local` called from outside of a `task::LocalSet`"); // Safety: Tasks are only polled and dropped from the thread that // spawns them. let (task, handle) = unsafe { task::joinable_local(future) }; cx.tasks.borrow_mut().queue.push_back(task); ha...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:10
/// 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 /// passed to `run` finishes, any local futures which have not completed /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
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 // `run_unchecked` is only called on threads that spawned the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
} 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(self:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
} } impl Drop for LocalSet { fn drop(&mut self) { self.with(|| { // Loop required here to ensure borrow is dropped between iterations #[allow(clippy::while_let_loop)] loop { let task = match self.context.tasks.borrow_mut().owned.pop_back() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
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
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
} } impl task::Schedule for Arc<Shared> { fn bind(task: Task<Self>) -> Arc<Shared> { CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("scheduler context missing"); cx.tasks.borrow_mut().owned.push_front(task); cx.shared.clone() }) } fn release(&self, t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/task/local.rs
561
591
tokio-rs/tokio:tokio/src/task/local.rs:4
} } /// State available from the thread-local struct Context { /// Owned task set and local run queue tasks: RefCell<Tasks>, /// State shared between threads. shared: Arc<Shared>, } struct Tasks { /// Collection of all active tasks spawned onto this executor. owned: LinkedList<Task<Arc<Shared...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/task/local.rs
121
180
tokio-rs/tokio:tokio/src/task/local.rs:5
cfg_rt_util! { /// Spawns a `!Send` future on the local task set. /// /// The spawned future will be run on the same thread that called `spawn_local.` /// This may only be called from the context of a local task set. /// /// # Panics /// /// - This function panics if called outside of a ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/task/local.rs
161
220
tokio-rs/tokio:tokio/src/task/local.rs:10
/// 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
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
// // 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
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
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(self: Pin<&m...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
impl Drop for LocalSet { fn drop(&mut self) { self.with(|| { // Loop required here to ensure borrow is dropped between iterations #[allow(clippy::while_let_loop)] loop { let task = match self.context.tasks.borrow_mut().owned.pop_back() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
.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::Ready(output); }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
impl task::Schedule for Arc<Shared> { fn bind(task: Task<Self>) -> Arc<Shared> { CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("scheduler context missing"); cx.tasks.borrow_mut().owned.push_front(task); cx.shared.clone() }) } fn release(&self, task: ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/53ccfc1fd694ee70c7a4d1e7af09a856bafb49e5/tokio/src/task/local.rs
561
589
tokio-rs/tokio:tokio/src/task/local.rs:3
/// /// ```rust /// use tokio::{task, time}; /// use std::rc::Rc; /// /// #[tokio::main] /// async fn main() { /// let unsend_data = Rc::new("world"); /// let local = task::LocalSet::new(); /// /// let unsend_data2 = unsend_data.clone(); /// local.spawn_local(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/task/local.rs
81
140
tokio-rs/tokio:tokio/src/task/local.rs:3
/// /// ```rust /// use tokio::{task, time}; /// use std::rc::Rc; /// /// #[tokio::main] /// async fn main() { /// let unsend_data = Rc::new("world"); /// let local = task::LocalSet::new(); /// /// let unsend_data2 = unsend_data.clone(); /// local.spawn_local(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/src/task/local.rs
81
140
tokio-rs/tokio:tokio/src/task/local.rs:4
} } /// State available from the thread-local struct Context { /// Owned task set and local run queue tasks: RefCell<Tasks>, /// State shared between threads. shared: Arc<Shared>, } struct Tasks { /// Collection of all active tasks spawned onto this executor. owned: LinkedList<Task<Arc<Shared...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
d600ab9a8f37e9eff3fa8587069a816b65b6da0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/src/task/local.rs
121
180
tokio-rs/tokio:tokio/src/task/local.rs:5
cfg_rt_util! { /// Spawns a `!Send` future on the local task set. /// /// The spawned future will be run on the same thread that called `spawn_local.` /// This may only be called from the context of a local task set. /// /// # Panics /// /// - This function panics if called outside of a ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/local.rs
161
220
tokio-rs/tokio:tokio/src/task/local.rs:6
// Safety: Tasks are only polled and dropped from the thread that // spawns them. let (task, handle) = unsafe { task::joinable_local(future) }; cx.tasks.borrow_mut().queue.push_back(task); handle }) } } /// Initial queue capacity const INITIAL_CAPACITY: usize...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:10
/// will remain on the local set, and will be driven on subsequent calls to /// `run_until` or when [awaiting the local set] itself. /// /// # Examples /// /// ```rust /// use tokio::task; /// /// #[tokio::main] /// async fn main() { /// task::LocalSet::new().run_until(async ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
// 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 // `spawn_local` spawns into the `LocalSet` on the current // thread, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
} } 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
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
fn drop(&mut self) { self.with(|| { // Loop required here to ensure borrow is dropped between iterations #[allow(clippy::while_let_loop)] loop { let task = match self.context.tasks.borrow_mut().owned.pop_back() { Some(task) => task, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
.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.local_set.tick() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
fn bind(task: Task<Self>) -> Arc<Shared> { CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("scheduler context missing"); cx.tasks.borrow_mut().owned.push_front(task); cx.shared.clone() }) } fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/local.rs
561
587
tokio-rs/tokio:tokio/src/task/local.rs:3
/// /// ```rust /// use tokio::{task, time}; /// use std::rc::Rc; /// /// #[tokio::main] /// async fn main() { /// let unsend_data = Rc::new("world"); /// let local = task::LocalSet::new(); /// /// let unsend_data2 = unsend_data.clone(); /// local.spawn_local(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4748b2571fc02d5ebbfe59e457f0e8d8ef0eb5f3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4748b2571fc02d5ebbfe59e457f0e8d8ef0eb5f3/tokio/src/task/local.rs
81
140
tokio-rs/tokio:tokio/src/task/local.rs:11
// 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 // `spawn_local` spawns into the `LocalSet` on the current // thread, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
20b5df90372ac97d817d2e3666773dd9561f057f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/20b5df90372ac97d817d2e3666773dd9561f057f/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
} } 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
20b5df90372ac97d817d2e3666773dd9561f057f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/20b5df90372ac97d817d2e3666773dd9561f057f/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
} } impl Drop for LocalSet { fn drop(&mut self) { self.with(|| { // Loop required here to ensure borrow is dropped between iterations #[allow(clippy::while_let_loop)] loop { let task = match self.context.tasks.borrow_mut().owned.pop_back() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
20b5df90372ac97d817d2e3666773dd9561f057f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/20b5df90372ac97d817d2e3666773dd9561f057f/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
me.local_set .context .shared .waker .register_by_ref(cx.waker()); let _no_blocking = crate::runtime::enter::disallow_blocking(); // Reset any previous task budget so that the future passed to // `run_until` and any tas...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
20b5df90372ac97d817d2e3666773dd9561f057f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/20b5df90372ac97d817d2e3666773dd9561f057f/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
} fn ptr_eq(&self, other: &Shared) -> bool { self as *const _ == other as *const _ } } impl task::Schedule for Arc<Shared> { fn bind(task: Task<Self>) -> Arc<Shared> { CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("scheduler context missing"); cx.tasks.borrow_m...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
20b5df90372ac97d817d2e3666773dd9561f057f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/20b5df90372ac97d817d2e3666773dd9561f057f/tokio/src/task/local.rs
561
595
tokio-rs/tokio:tokio/src/task/local.rs:13
fn drop(&mut self) { self.with(|| { // Loop required here to ensure borrow is dropped between iterations #[allow(clippy::while_let_loop)] loop { let task = match self.context.tasks.borrow_mut().owned.pop_back() { Some(task) => task, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
.register_by_ref(cx.waker()); let _no_blocking = crate::runtime::enter::disallow_blocking(); if let Poll::Ready(output) = me.future.poll(cx) { return Poll::Ready(output); } if me.local_set.tick() { // If `tick` returns `true`, we need to...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("scheduler context missing"); cx.tasks.borrow_mut().owned.push_front(task); cx.shared.clone() }) } fn release(&self, task: &Task<Self>) -> Option<Task<Self>> { use std::ptr::NonNull; CURRENT.with(|ma...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/task/local.rs
561
586
tokio-rs/tokio:tokio/src/task/local.rs:13
fn drop(&mut self) { self.with(|| { // Loop required here to ensure borrow is dropped between iterations #[allow(clippy::while_let_loop)] loop { let task = match self.context.tasks.borrow_mut().owned.pop_back() { Some(task) => task, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
9553355c2709235686030bb1a299dc83a053347c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9553355c2709235686030bb1a299dc83a053347c/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
.register_by_ref(cx.waker()); if let Poll::Ready(output) = me.future.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 rem...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
9553355c2709235686030bb1a299dc83a053347c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9553355c2709235686030bb1a299dc83a053347c/tokio/src/task/local.rs
521
580
tokio-rs/tokio:tokio/src/task/local.rs:15
cx.tasks.borrow_mut().owned.push_front(task); cx.shared.clone() }) } 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.shar...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
9553355c2709235686030bb1a299dc83a053347c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9553355c2709235686030bb1a299dc83a053347c/tokio/src/task/local.rs
561
584
tokio-rs/tokio:tokio/src/task/local.rs:3
/// /// ```rust /// use tokio::{task, time}; /// use std::rc::Rc; /// /// #[tokio::main] /// async fn main() { /// let unsend_data = Rc::new("world"); /// let local = task::LocalSet::new(); /// /// let unsend_data2 = unsend_data.clone(); /// local.spawn_local(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
4fc2adae4fcc76fa8ff1169fed3db6d7c9100c4a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4fc2adae4fcc76fa8ff1169fed3db6d7c9100c4a/tokio/src/task/local.rs
81
140
tokio-rs/tokio:tokio/src/task/local.rs:3
/// ```rust /// use tokio::{task, time}; /// use std::rc::Rc; /// /// #[tokio::main] /// async fn main() { /// let unsend_data = Rc::new("world"); /// let local = task::LocalSet::new(); /// /// let unsend_data2 = unsend_data.clone(); /// local.spawn_local(async mo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f39c15334e74b07a44efaa0f7201262e17e4f062
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/task/local.rs
81
140
tokio-rs/tokio:tokio/src/task/local.rs:4
struct Context { /// Owned task set and local run queue tasks: RefCell<Tasks>, /// State shared between threads. shared: Arc<Shared>, } struct Tasks { /// Collection of all active tasks spawned onto this executor. owned: LinkedList<Task<Arc<Shared>>>, /// Local run queue sender and receiv...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f39c15334e74b07a44efaa0f7201262e17e4f062
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/task/local.rs
121
180
tokio-rs/tokio:tokio/src/task/local.rs:5
/// This may only be called from the context of a local task set. /// /// # Panics /// /// - This function panics if called outside of a local task set. /// /// # Examples /// /// ```rust /// use std::rc::Rc; /// use tokio::task; /// /// #[tokio::main] /// async fn ma...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f39c15334e74b07a44efaa0f7201262e17e4f062
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/task/local.rs
161
220
tokio-rs/tokio:tokio/src/task/local.rs:6
cx.tasks.borrow_mut().queue.push_back(task); handle }) } } /// 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 L...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f39c15334e74b07a44efaa0f7201262e17e4f062
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:13
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
f39c15334e74b07a44efaa0f7201262e17e4f062
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
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
f39c15334e74b07a44efaa0f7201262e17e4f062
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/task/local.rs
521
579
tokio-rs/tokio:tokio/src/task/local.rs:15
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()); // safety: task...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f39c15334e74b07a44efaa0f7201262e17e4f062
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/task/local.rs
561
579
tokio-rs/tokio:tokio/src/task/local.rs:3
/// ```rust /// use tokio::{task, time}; /// use std::rc::Rc; /// /// #[tokio::main] /// async fn main() { /// let unsend_data = Rc::new("world"); /// let local = task::LocalSet::new(); /// /// let unsend_data2 = unsend_data.clone(); /// local.spawn_local(async mo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/task/local.rs
81
140
tokio-rs/tokio:tokio/src/task/local.rs:10
/// ```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
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:10
/// ```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
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
Some(task) => 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
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:3
/// use std::rc::Rc; /// /// #[tokio::main] /// async fn main() { /// let unsend_data = Rc::new("world"); /// let local = task::LocalSet::new(); /// /// let unsend_data2 = unsend_data.clone(); /// local.spawn_local(async move { /// // ... /// print...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f9ddb93604a830d106475bd4c4cae436fafcc0da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/local.rs
81
140
tokio-rs/tokio:tokio/src/task/local.rs:4
/// Used to notify the `LocalFuture` when a task in the local task set is /// notified. waker: AtomicWaker, } pin_project! { #[derive(Debug)] struct LocalFuture<F> { scheduler: Rc<Scheduler>, #[pin] future: F, } } thread_local! { static CURRENT_TASK_SET: Cell<Option<Non...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f9ddb93604a830d106475bd4c4cae436fafcc0da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/local.rs
121
180
tokio-rs/tokio:tokio/src/task/local.rs:5
/// // Run the local task set. /// local.run_until(async move { /// let unsend_data = unsend_data.clone(); /// task::spawn_local(async move { /// println!("{}", unsend_data); /// // ... /// }).await.unwrap(); /// }).await; /// }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f9ddb93604a830d106475bd4c4cae436fafcc0da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/local.rs
161
220
tokio-rs/tokio:tokio/src/task/local.rs:6
scheduler: Rc::new(Scheduler::new()), } } /// Spawns a `!Send` task onto the local task set. /// /// This task is guaranteed to be run on the current thread. /// /// Unlike the free function [`spawn_local`], this method may be used to /// spawn local tasks when the task set is _not_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f9ddb93604a830d106475bd4c4cae436fafcc0da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:9
rt.block_on(self.run_until(future)) } /// Run 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 t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f9ddb93604a830d106475bd4c4cae436fafcc0da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
impl Future for LocalSet { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { let scheduler = self.as_ref().scheduler.clone(); scheduler.waker.register_by_ref(cx.waker()); if scheduler.with(|| scheduler.tick()) { // If `tick` retur...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f9ddb93604a830d106475bd4c4cae436fafcc0da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
scheduler.waker.register_by_ref(cx.waker()); scheduler.with(|| { if let Poll::Ready(output) = future.as_mut().poll(cx) { return Poll::Ready(output); } if scheduler.tick() { // If `tick` returns `true`, we need to notify the local future again:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f9ddb93604a830d106475bd4c4cae436fafcc0da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
if self.is_current() { unsafe { self.queues.push_local(task) }; } else { let mut lock = self.queues.remote(); lock.schedule(task, false); self.waker.wake(); drop(lock); } } } impl Scheduler { fn new() -> Self { Self { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f9ddb93604a830d106475bd4c4cae436fafcc0da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
fn is_current(&self) -> bool { CURRENT_TASK_SET .try_with(|current| { current .get() .iter() .any(|current| ptr::eq(current.as_ptr(), self as *const _)) }) .unwrap_or(false) } /// Tick the sc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f9ddb93604a830d106475bd4c4cae436fafcc0da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/local.rs
481
540
tokio-rs/tokio:tokio/src/task/local.rs:14
true } fn is_empty(&self) -> bool { unsafe { // safety: this method may not be called from threads other than the // thread that owns the `Queues`. since `Scheduler` is not `Send` or // `Sync`, that shouldn't happen. !self.queues.has_tasks_remaining() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
f9ddb93604a830d106475bd4c4cae436fafcc0da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/local.rs
521
558
tokio-rs/tokio:tokio/src/task/local.rs:6
scheduler: Rc::new(Scheduler::new()), } } /// Spawns a `!Send` task onto the local task set. /// /// This task is guaranteed to be run on the current thread. /// /// Unlike the free function [`spawn_local`], this method may be used to /// spawn local tasks when the task set is _not_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
798e86821f6e06fba552bd670c5887ce3b6ff698
github
async-runtime
https://github.com/tokio-rs/tokio/blob/798e86821f6e06fba552bd670c5887ce3b6ff698/tokio/src/task/local.rs
201
260
tokio-rs/tokio:tokio/src/task/local.rs:10
impl Future for LocalSet { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { let scheduler = self.as_ref().scheduler.clone(); scheduler.waker.register_by_ref(cx.waker()); if scheduler.with(|| scheduler.tick()) { // If `tick` retur...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
798e86821f6e06fba552bd670c5887ce3b6ff698
github
async-runtime
https://github.com/tokio-rs/tokio/blob/798e86821f6e06fba552bd670c5887ce3b6ff698/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
scheduler.waker.register_by_ref(cx.waker()); scheduler.with(|| { if let Poll::Ready(output) = future.as_mut().poll(cx) { return Poll::Ready(output); } if scheduler.tick() { // If `tick` returns true, we need to notify the local future again: ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
798e86821f6e06fba552bd670c5887ce3b6ff698
github
async-runtime
https://github.com/tokio-rs/tokio/blob/798e86821f6e06fba552bd670c5887ce3b6ff698/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:2
/// // ... /// }).await.unwrap(); /// }); /// ``` /// In order to spawn `!Send` futures, we can use a local task set to /// schedule them on the thread calling [`Runtime::block_on`]. When running /// inside of the local task set, we can use [`task::spawn_local`], which can /// sp...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
41d15ea212525f4be310d65c29c626488af546e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/41d15ea212525f4be310d65c29c626488af546e1/tokio/src/task/local.rs
41
100
tokio-rs/tokio:tokio/src/task/local.rs:3
} #[derive(Debug)] struct Scheduler { tick: Cell<u8>, queues: MpscQueues<Self>, /// Used to notify the `LocalFuture` when a task in the local task set is /// notified. waker: AtomicWaker, } pin_project! { struct LocalFuture<F> { scheduler: Rc<Scheduler>, #[pin] future...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
41d15ea212525f4be310d65c29c626488af546e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/41d15ea212525f4be310d65c29c626488af546e1/tokio/src/task/local.rs
81
140
tokio-rs/tokio:tokio/src/task/local.rs:4
/// use tokio::task; /// /// let unsend_data = Rc::new("my unsend data..."); /// /// let mut rt = Runtime::new().unwrap(); /// let local = task::LocalSet::new(); /// /// // Run the local task set. /// local.block_on(&mut rt, async move { /// let unsend_data = unsend_data.clone();...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
41d15ea212525f4be310d65c29c626488af546e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/41d15ea212525f4be310d65c29c626488af546e1/tokio/src/task/local.rs
121
180
tokio-rs/tokio:tokio/src/task/local.rs:5
const MAX_TASKS_PER_TICK: usize = 61; impl LocalSet { /// Returns a new local task set. pub fn new() -> Self { Self { scheduler: Rc::new(Scheduler::new()), } } /// Spawns a `!Send` task onto the local task set. /// /// This task is guaranteed to be run on the curren...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
41d15ea212525f4be310d65c29c626488af546e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/41d15ea212525f4be310d65c29c626488af546e1/tokio/src/task/local.rs
161
220
tokio-rs/tokio:tokio/src/task/local.rs:7
/// issued from a local task, the [`spawn_blocking`] API may be used instead. /// /// For example, this will panic: /// ```should_panic /// use tokio::runtime::Runtime; /// use tokio::task; /// /// let mut rt = Runtime::new().unwrap(); /// let local = task::LocalSet::new(); /// local...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
41d15ea212525f4be310d65c29c626488af546e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/41d15ea212525f4be310d65c29c626488af546e1/tokio/src/task/local.rs
241
300
tokio-rs/tokio:tokio/src/task/local.rs:8
/// [`spawn_blocking`]: ../blocking/fn.spawn_blocking.html pub fn block_on<F>(&self, rt: &mut crate::runtime::Runtime, future: F) -> F::Output where F: Future, { let scheduler = self.scheduler.clone(); self.scheduler .with(move || rt.block_on(LocalFuture { scheduler, futu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
41d15ea212525f4be310d65c29c626488af546e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/41d15ea212525f4be310d65c29c626488af546e1/tokio/src/task/local.rs
281
340
tokio-rs/tokio:tokio/src/task/local.rs:9
// === impl Scheduler === impl Schedule for Scheduler { fn bind(&self, task: &Task<Self>) { assert!(self.is_current()); unsafe { self.queues.add_task(task); } } fn release(&self, task: Task<Self>) { // This will be called when dropping the local runtime. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
41d15ea212525f4be310d65c29c626488af546e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/41d15ea212525f4be310d65c29c626488af546e1/tokio/src/task/local.rs
321
380
tokio-rs/tokio:tokio/src/task/local.rs:10
queues: MpscQueues::new(), waker: AtomicWaker::new(), } } fn with<F>(&self, f: impl FnOnce() -> F) -> F { struct Entered<'a> { current: &'a Cell<Option<NonNull<Scheduler>>>, } impl<'a> Drop for Entered<'a> { fn drop(&mut self) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
41d15ea212525f4be310d65c29c626488af546e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/41d15ea212525f4be310d65c29c626488af546e1/tokio/src/task/local.rs
361
420
tokio-rs/tokio:tokio/src/task/local.rs:11
let tick = self.tick.get().wrapping_add(1); self.tick.set(tick); let task = match unsafe { // safety: we must be on the local thread to call this. The assertion // the top of this method ensures that `tick` is only called locally. self.queues.next...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
41d15ea212525f4be310d65c29c626488af546e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/41d15ea212525f4be310d65c29c626488af546e1/tokio/src/task/local.rs
401
460
tokio-rs/tokio:tokio/src/task/local.rs:12
self.queues.drain_pending_drop(); self.queues.drain_queues(); if !self.queues.has_tasks_remaining() { break; } std::thread::yield_now(); } } } } #[cfg(all(test, not(loom)))] mod tests { use super::*; u...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
41d15ea212525f4be310d65c29c626488af546e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/41d15ea212525f4be310d65c29c626488af546e1/tokio/src/task/local.rs
441
500
tokio-rs/tokio:tokio/src/task/local.rs:13
LocalSet::new().block_on(&mut rt, async { assert!(ON_RT_THREAD.with(|cell| cell.get())); spawn_local(async { assert!(ON_RT_THREAD.with(|cell| cell.get())); }) .await .unwrap(); }); } #[test] fn local_threadpool_timer() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/local.rs
MIT
41d15ea212525f4be310d65c29c626488af546e1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/41d15ea212525f4be310d65c29c626488af546e1/tokio/src/task/local.rs
481
540