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/runtime/thread_pool/worker.rs:20
core.shutdown(); } // Drain the injection queue while let Some(task) = self.inject.pop() { task.shutdown(); } } fn ptr_eq(&self, other: &Shared) -> bool { std::ptr::eq(self, other) } }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
2087f3e0ebb08d633d59c5f964b3901e68b3c038
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/tokio/src/runtime/thread_pool/worker.rs
761
773
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:1
//! A scheduler is initialized with a fixed number of workers. Each worker is //! driven by a thread. Each worker has a "core" which contains data such as the //! run queue and other state. When `block_in_place` is called, the worker's //! "core" is handed off to a new thread allowing the scheduler to continue to //! m...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
1
60
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2
/// queue. This effectively results in the **last** scheduled task to be run /// next (LIFO). This is an optimization for message passing patterns and /// helps to reduce latency. lifo_slot: Option<Notified>, /// The worker-local run queue. run_queue: queue::Local<Arc<Worker>>, /// True if the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
41
100
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:3
/// Cores that have observed the shutdown signal /// /// The core is **not** placed back in the worker to avoid it from being /// stolen by a thread that was spawned as part of `block_in_place`. #[allow(clippy::vec_box)] // we're moving an already-boxed value shutdown_cores: Mutex<Vec<Box<Core>>>, }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
81
140
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4
// Tracks thread-local state scoped_thread_local!(static CURRENT: Context); pub(super) fn create(size: usize, park: Parker) -> (Arc<Shared>, Launch) { let mut cores = vec![]; let mut remotes = vec![]; // Create the local queues for _ in 0..size { let (steal, run_queue) = queue::local(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
121
180
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:5
index, core: AtomicCell::new(Some(core)), })); } (shared, launch) } pub(crate) fn block_in_place<F, R>(f: F) -> R where F: FnOnce() -> R, { // Try to steal the worker core back struct Reset(coop::Budget); impl Drop for Reset { fn drop(&mut self) { CURRE...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
161
220
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
} (EnterContext::Entered { allow_blocking }, false) => { // We are on an executor, but _not_ on the thread pool. That is // _only_ okay if we are in a thread pool runtime's block_on // method: if allow_blocking { had_entere...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
// First, move the core back into the worker's shared core slot. cx.worker.core.set(core); // Next, clone the worker handle and send it to a new thread for // processing. // // Once the blocking task is done executing, we will attempt to // steal the core back. l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
let core = match worker.core.take() { Some(core) => core, None => return, }; // Set the worker context. let cx = Context { worker, core: RefCell::new(None), }; let _enter = crate::runtime::enter(true); CURRENT.set(&cx, || { // This should always be an e...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
// Wait for work core = self.park(core); } } core.pre_shutdown(&self.worker); // Signal shutdown self.worker.shared.shutdown(core); Err(()) } fn run_task(&self, task: Notified, mut core: Box<Core>) -> RunResult { // Make sure the wor...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
if coop::has_budget_remaining() { // Run the LIFO task, then loop *self.core.borrow_mut() = Some(core); task.run(); } else { // Not enough budget left to run the LIFO task, push it to // the back of the q...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11
core } fn park_timeout(&self, mut core: Box<Core>, duration: Option<Duration>) -> Box<Core> { // Take the parker out of core let mut park = core.park.take().expect("park missing"); // Store `core` in context *self.core.borrow_mut() = Some(core); // Park thread ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
401
460
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12
fn next_task(&mut self, worker: &Worker) -> Option<Notified> { if self.tick % GLOBAL_POLL_INTERVAL == 0 { worker.inject().pop().or_else(|| self.next_local_task()) } else { self.next_local_task().or_else(|| worker.inject().pop()) } } fn next_local_task(&mut self) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
441
500
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13
if !self.is_searching { self.is_searching = worker.shared.idle.transition_worker_to_searching(); } self.is_searching } fn transition_from_searching(&mut self, worker: &Worker) { if !self.is_searching { return; } self.is_searching = false; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
481
540
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
worker.shared.idle.unpark_worker_by_id(worker.index); self.is_searching = true; return true; } if worker.shared.idle.is_parked(worker.index) { return false; } // When unparked, the worker is in the searching state. self.is_searching = true; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
} } impl Worker { /// Returns a reference to the scheduler's injection queue fn inject(&self) -> &Inject<Arc<Worker>> { &self.shared.inject } } impl task::Schedule for Arc<Worker> { fn bind(task: Task) -> Arc<Worker> { CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("sch...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
} } impl Shared { pub(super) fn schedule(&self, task: Notified, is_yield: bool) -> Result<(), Notified> { CURRENT.with(|maybe_cx| { if let Some(cx) = maybe_cx { // Make sure the task is part of the **current** scheduler. if self.ptr_eq(&cx.worker.shared) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18
if !self.inject.is_empty() { self.notify_parked(); } } fn transition_worker_from_searching(&self) { if self.idle.transition_worker_from_searching() { // We are the final searching worker. Because work was found, we // need to notify another worker. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
3b38ebd7f5d50611193f942c31c57262f263be33
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3b38ebd7f5d50611193f942c31c57262f263be33/tokio/src/runtime/thread_pool/worker.rs
681
721
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:1
//! A scheduler is initialized with a fixed number of workers. Each worker is //! driven by a thread. Each worker has a "core" which contains data such as the //! run queue and other state. When `block_in_place` is called, the worker's //! "core" is handed off to a new thread allowing the scheduler to continue to //! m...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
e2589a0e401e27457618920e66caa0f14e9a69ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e2589a0e401e27457618920e66caa0f14e9a69ad/tokio/src/runtime/thread_pool/worker.rs
1
60
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2
/// queue. This effectively results in the **last** scheduled task to be run /// next (LIFO). This is an optimization for message passing patterns and /// helps to reduce latency. lifo_slot: Option<Notified>, /// The worker-local run queue. run_queue: queue::Local<Arc<Worker>>, /// True if the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
e2589a0e401e27457618920e66caa0f14e9a69ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e2589a0e401e27457618920e66caa0f14e9a69ad/tokio/src/runtime/thread_pool/worker.rs
41
100
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4
// Tracks thread-local state scoped_thread_local!(static CURRENT: Context); pub(super) fn create(size: usize, park: Parker) -> (Arc<Shared>, Launch) { let mut cores = vec![]; let mut remotes = vec![]; // Create the local queues for _ in 0..size { let (steal, run_queue) = queue::local(); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
e2589a0e401e27457618920e66caa0f14e9a69ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e2589a0e401e27457618920e66caa0f14e9a69ad/tokio/src/runtime/thread_pool/worker.rs
121
180
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
worker.shared.idle.unpark_worker_by_id(worker.index); self.is_searching = true; return true; } if worker.shared.idle.is_parked(worker.index) { return false; } // When unparked, the worker is in the searching state. self.is_searching = true; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
e2589a0e401e27457618920e66caa0f14e9a69ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e2589a0e401e27457618920e66caa0f14e9a69ad/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
} } impl Worker { /// Returns a reference to the scheduler's injection queue fn inject(&self) -> &queue::Inject<Arc<Worker>> { &self.shared.inject } } impl task::Schedule for Arc<Worker> { fn bind(task: Task) -> Arc<Worker> { CURRENT.with(|maybe_cx| { let cx = maybe_cx.expe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
e2589a0e401e27457618920e66caa0f14e9a69ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e2589a0e401e27457618920e66caa0f14e9a69ad/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:1
//! A scheduler is initialized with a fixed number of workers. Each worker is //! driven by a thread. Each worker has a "core" which contains data such as the //! run queue and other state. When `block_in_place` is called, the worker's //! "core" is handed off to a new thread allowing the scheduler to continue to //! m...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
1
60
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2
/// queue. This effectively results in the **last** scheduled task to be run /// next (LIFO). This is an optimization for message passing patterns and /// helps to reduce latency. lifo_slot: Option<Notified>, /// The worker-local run queue. run_queue: queue::Local<Arc<Worker>>, /// True if the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
41
100
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:3
/// Cores that have observed the shutdown signal /// /// The core is **not** placed back in the worker to avoid it from being /// stolen by a thread that was spawned as part of `block_in_place`. #[allow(clippy::vec_box)] // we're moving an already-boxed value shutdown_cores: Mutex<Vec<Box<Core>>>, }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
81
140
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4
/// A notified task handle type Notified = task::Notified<Arc<Worker>>; // Tracks thread-local state scoped_thread_local!(static CURRENT: Context); pub(super) fn create(size: usize, park: Parker) -> (Arc<Shared>, Launch) { let mut cores = vec![]; let mut remotes = vec![]; // Create the local queues f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
121
180
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:5
shutdown_cores: Mutex::new(vec![]), }); let mut launch = Launch(vec![]); for (index, core) in cores.drain(..).enumerate() { launch.0.push(Arc::new(Worker { shared: shared.clone(), index, core: AtomicCell::new(Some(core)), })); } (shared, launch)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
161
220
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
let mut had_entered = false; CURRENT.with(|maybe_cx| { match (crate::runtime::enter::context(), maybe_cx.is_some()) { (EnterContext::Entered { .. }, true) => { // We are on a thread pool runtime thread, so we just need to set up blocking. had_entered = true; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
// The parker should be set here assert!(core.park.is_some()); // In order to block, the core must be sent to another thread for // execution. // // First, move the core back into the worker's shared core slot. cx.worker.core.set(core); // Next, clone the worker...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
} } fn run(worker: Arc<Worker>) { // Acquire a core. If this fails, then another thread is running this // worker and there is nothing further to do. let core = match worker.core.take() { Some(core) => core, None => return, }; // Set the worker context. let cx = Context { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
// There is no more **local** work to process, try to steal work // from other workers. if let Some(task) = core.steal_work(&self.worker) { core = self.run_task(task, core)?; } else { // Wait for work core = self.park(core); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
// Check for a task in the LIFO slot let task = match core.lifo_slot.take() { Some(task) => task, None => return Ok(core), }; if coop::has_budget_remaining() { // Run the LIFO task, then loop ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11
core.maintenance(&self.worker); if core.transition_from_parked(&self.worker) { return core; } } core } fn park_timeout(&self, mut core: Box<Core>, duration: Option<Duration>) -> Box<Core> { // Take the parker out of core let mut park = c...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
401
460
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12
/// Increment the tick fn tick(&mut self) { self.tick = self.tick.wrapping_add(1); } /// Return the next notified task available to this worker. fn next_task(&mut self, worker: &Worker) -> Option<Notified> { if self.tick % GLOBAL_POLL_INTERVAL == 0 { worker.inject().pop().or...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
441
500
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13
// Fallback on checking the global queue worker.shared.inject.pop() } fn transition_to_searching(&mut self, worker: &Worker) -> bool { if !self.is_searching { self.is_searching = worker.shared.idle.transition_worker_to_searching(); } self.is_searching } fn ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
481
540
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
/// Returns `true` if the transition happened. fn transition_from_parked(&mut self, worker: &Worker) -> bool { // If a task is in the lifo slot, then we must unpark regardless of // being notified if self.lifo_slot.is_some() { worker.shared.idle.unpark_worker_by_id(worker.index);...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
self.drain_pending_drop(worker); if self.tasks.is_empty() { break; } // Wait until signalled let park = self.park.as_mut().expect("park missing"); park.park().expect("park failed"); } } // Shutdown the core fn shutdown(&m...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
} } } impl Worker { /// Returns a reference to the scheduler's injection queue fn inject(&self) -> &queue::Inject<Arc<Worker>> { &self.shared.inject } /// Return a reference to this worker's remote data fn remote(&self) -> &Remote { &self.shared.remotes[self.index] } f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
enum Immediate { // Task has been synchronously removed from the Core owned by the // current thread Removed(Option<Task>), // Task is owned by another thread, so we need to notify it to clean // up the task later. MaybeRemote, } l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
641
700
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18
Immediate::Removed(task) => return task, Immediate::MaybeRemote => (), }; // Track the task to be released by the worker that owns it // // Safety: We get a new handle without incrementing the ref-count. // A ref-count is held by the "owned" linked list and it is onl...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
681
740
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:19
// here. let _ = self.shared.schedule(task, true); } } impl Shared { pub(super) fn schedule(&self, task: Notified, is_yield: bool) -> Result<(), Notified> { CURRENT.with(|maybe_cx| { if let Some(cx) = maybe_cx { // Make sure the task is part of the **current** schedu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
721
780
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20
core.run_queue.push_back(prev, &self.inject); } core.lifo_slot = Some(task); ret }; // Only notify if not currently parked. If `park` is `None`, then the // scheduling is from a resource driver. As notifications often come in // batches, the notific...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
761
820
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:21
} if !self.inject.is_empty() { self.notify_parked(); } } fn transition_worker_from_searching(&self) { if self.idle.transition_worker_from_searching() { // We are the final searching worker. Because work was found, we // need to notify another worker....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
7601dc6d2a5c2902e78e220f44646960f910f38f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7601dc6d2a5c2902e78e220f44646960f910f38f/tokio/src/runtime/thread_pool/worker.rs
801
841
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18
Immediate::Removed(task) => return task, Immediate::MaybeRemote => (), }; // Track the task to be released by the worker that owns it // // Safety: We get a new handle without incrementing the ref-count. // A ref-count is held by the "owned" linked list and it is onl...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a39e6c2439927ed9c73043401959b0b02d054630
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a39e6c2439927ed9c73043401959b0b02d054630/tokio/src/runtime/thread_pool/worker.rs
681
740
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:19
pub(super) fn schedule(&self, task: Notified, is_yield: bool) { CURRENT.with(|maybe_cx| { if let Some(cx) = maybe_cx { // Make sure the task is part of the **current** scheduler. if self.ptr_eq(&cx.worker.shared) { // And the current thread still h...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a39e6c2439927ed9c73043401959b0b02d054630
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a39e6c2439927ed9c73043401959b0b02d054630/tokio/src/runtime/thread_pool/worker.rs
721
780
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20
// Only notify if not currently parked. If `park` is `None`, then the // scheduling is from a resource driver. As notifications often come in // batches, the notification is delayed until the park is complete. if should_notify && core.park.is_some() { self.notify_parked(); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a39e6c2439927ed9c73043401959b0b02d054630
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a39e6c2439927ed9c73043401959b0b02d054630/tokio/src/runtime/thread_pool/worker.rs
761
820
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:21
fn transition_worker_from_searching(&self) { if self.idle.transition_worker_from_searching() { // We are the final searching worker. Because work was found, we // need to notify another worker. self.notify_parked(); } } /// Signals that a worker has observed ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a39e6c2439927ed9c73043401959b0b02d054630
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a39e6c2439927ed9c73043401959b0b02d054630/tokio/src/runtime/thread_pool/worker.rs
801
834
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:21
fn transition_worker_from_searching(&self) { if self.idle.transition_worker_from_searching() { // We are the final searching worker. Because work was found, we // need to notify another worker. self.notify_parked(); } } /// Signals that a worker has observed ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
bcb95db4e2d4a9a43a3f3f5e129ddb7232599451
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bcb95db4e2d4a9a43a3f3f5e129ddb7232599451/tokio/src/runtime/thread_pool/worker.rs
801
832
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:21
fn transition_worker_from_searching(&self) { if self.idle.transition_worker_from_searching() { // We are the final searching worker. Because work was found, we // need to notify another worker. self.notify_parked(); } } /// Signals that a worker has observed ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
2d9bea8d63229c108f25049c4815538ada25697a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2d9bea8d63229c108f25049c4815538ada25697a/tokio/src/runtime/thread_pool/worker.rs
801
832
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
} } fn run(worker: Arc<Worker>) { // Acquire a core. If this fails, then another thread is running this // worker and there is nothing further to do. let core = match worker.core.take() { Some(core) => core, None => return, }; // Set the worker context. let cx = Context { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
57dffb9dfe9e4c0f12429246540add3975f4a754
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57dffb9dfe9e4c0f12429246540add3975f4a754/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
// There is no more **local** work to process, try to steal work // from other workers. if let Some(task) = core.steal_work(&self.worker) { core = self.run_task(task, core)?; } else { // Wait for work core = self.park(core); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
57dffb9dfe9e4c0f12429246540add3975f4a754
github
async-runtime
https://github.com/tokio-rs/tokio/blob/57dffb9dfe9e4c0f12429246540add3975f4a754/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2
/// queue. This effectively results in the **last** scheduled task to be run /// next (LIFO). This is an optimization for message passing patterns and /// helps to reduce latency. lifo_slot: Option<Notified>, /// The worker-local run queue. run_queue: queue::Local<Arc<Worker>>, /// True if the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
41
100
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:3
/// Workers have have observed the shutdown signal /// /// The core is **not** placed back in the worker to avoid it from being /// stolen by a thread that was spawned as part of `block_in_place`. shutdown_workers: Mutex<Vec<(Box<Core>, Arc<Worker>)>>, } /// Used to communicate with a worker from other...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
81
140
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4
/// A notified task handle type Notified = task::Notified<Arc<Worker>>; // Tracks thread-local state scoped_thread_local!(static CURRENT: Context); pub(super) fn create(size: usize, park: Parker) -> (Arc<Shared>, Launch) { let mut cores = vec![]; let mut remotes = vec![]; // Create the local queues f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
121
180
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:5
}); let mut launch = Launch(vec![]); for (index, core) in cores.drain(..).enumerate() { launch.0.push(Arc::new(Worker { shared: shared.clone(), index, core: AtomicCell::new(Some(core)), })); } (shared, launch) } pub(crate) fn block_in_place<F, R>(f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
161
220
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
CURRENT.with(|maybe_cx| { match (crate::runtime::enter::context(), maybe_cx.is_some()) { (EnterContext::Entered { .. }, true) => { // We are on a thread pool runtime thread, so we just need to set up blocking. had_entered = true; } (EnterContex...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
} fn run(worker: Arc<Worker>) { // Acquire a core. If this fails, then another thread is running this // worker and there is nothing further to do. let core = match worker.core.take() { Some(core) => core, None => return, }; // Set the worker context. let cx = Context { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
// There is no more **local** work to process, try to steal work // from other workers. if let Some(task) = core.steal_work(&self.worker) { core = self.run_task(task, core)?; } else { // Wait for work core = self.park(core); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
None => return Ok(core), }; if coop::has_budget_remaining() { // Run the LIFO task, then loop *self.core.borrow_mut() = Some(core); task.run(); } else { // Not enough budget left to run the L...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11
return core; } } core } fn park_timeout(&self, mut core: Box<Core>, duration: Option<Duration>) -> Box<Core> { // Take the parker out of core let mut park = core.park.take().expect("park missing"); // Store `core` in context *self.core.borrow_mut() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
401
460
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12
} /// Return the next notified task available to this worker. fn next_task(&mut self, worker: &Worker) -> Option<Notified> { if self.tick % GLOBAL_POLL_INTERVAL == 0 { worker.inject().pop().or_else(|| self.next_local_task()) } else { self.next_local_task().or_else(|| wor...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
441
500
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13
} fn transition_to_searching(&mut self, worker: &Worker) -> bool { if !self.is_searching { self.is_searching = worker.shared.idle.transition_worker_to_searching(); } self.is_searching } fn transition_from_searching(&mut self, worker: &Worker) { if !self.is_sear...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
481
540
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
// If a task is in the lifo slot, then we must unpark regardless of // being notified if self.lifo_slot.is_some() { worker.shared.idle.unpark_worker_by_id(worker.index); self.is_searching = true; return true; } if worker.shared.idle.is_parked(worker.i...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
if self.tasks.is_empty() { break; } // Wait until signalled park.park().expect("park failed"); } // Drain the queue while self.next_local_task().is_some() {} park.shutdown(); } fn drain_pending_drop(&mut self, worker: &Worke...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
/// Return a reference to this worker's remote data fn remote(&self) -> &Remote { &self.shared.remotes[self.index] } fn eq(&self, other: &Worker) -> bool { self.shared.ptr_eq(&other.shared) && self.index == other.index } } impl task::Schedule for Arc<Worker> { fn bind(task: Task) -...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
}; if !self.eq(&cx.worker) { return Immediate::Core(cx.core.borrow().is_some()); } let mut maybe_core = cx.core.borrow_mut(); if let Some(core) = &mut *maybe_core { // Directly remove the task // // safety...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
641
700
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18
let task = unsafe { Task::from_raw(task.header().into()) }; self.remote().pending_drop.push(task); if worker_has_core { return None; } // The worker core has been handed off to another thread. In the // event that the scheduler is currently shutting down, the threa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
681
740
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:19
} // Otherwise, use the inject queue self.inject.push(task); self.notify_parked(); }); } fn schedule_local(&self, core: &mut Core, task: Notified, is_yield: bool) { // Spawning from the worker thread. If scheduling a "yield" then the // task must alw...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
721
780
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20
self.notify_all(); } } fn notify_parked(&self) { if let Some(index) = self.idle.worker_to_notify() { self.remotes[index].unpark.unpark(); } } fn notify_all(&self) { for remote in &self.remotes[..] { remote.unpark.unpark(); } } fn...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
761
820
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:21
/// If all workers have reached this point, the final cleanup is performed. fn shutdown(&self, core: Box<Core>, worker: Arc<Worker>) { let mut workers = self.shutdown_workers.lock(); workers.push((core, worker)); if workers.len() != self.remotes.len() { return; } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a125ebd745f31098aa170cb1009ff0fe34508d37
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a125ebd745f31098aa170cb1009ff0fe34508d37/tokio/src/runtime/thread_pool/worker.rs
801
821
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
/// Return a reference to this worker's remote data fn remote(&self) -> &Remote { &self.shared.remotes[self.index] } fn eq(&self, other: &Worker) -> bool { self.shared.ptr_eq(&other.shared) && self.index == other.index } } impl task::Schedule for Arc<Worker> { fn bind(task: Task) -...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
// safety: the task is inserted in the list in `bind`. unsafe { let ptr = NonNull::from(task.header()); return core.tasks.remove(ptr); } } } // Track the task to be released by the worker tha...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/thread_pool/worker.rs
641
700
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18
self.shared.schedule(task, false); } fn yield_now(&self, task: Notified) { self.shared.schedule(task, true); } } impl Shared { pub(super) fn schedule(&self, task: Notified, is_yield: bool) { CURRENT.with(|maybe_cx| { if let Some(cx) = maybe_cx { // Make sure...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/thread_pool/worker.rs
681
740
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:19
if let Some(prev) = prev { core.run_queue.push_back(prev, &self.inject); } core.lifo_slot = Some(task); ret }; // Only notify if not currently parked. If `park` is `None`, then the // scheduling is from a resource driver. As notifications of...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/thread_pool/worker.rs
721
780
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20
return; } } if !self.inject.is_empty() { self.notify_parked(); } } fn transition_worker_from_searching(&self) { if self.idle.transition_worker_from_searching() { // We are the final searching worker. Because work was found, we // ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/thread_pool/worker.rs
761
801
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:1
//! A scheduler is initialized with a fixed number of workers. Each worker is //! driven by a thread. Each worker has a "core" which contains data such as the //! run queue and other state. When `block_in_place` is called, the worker's //! "core" is handed off to a new thread allowing the scheduler to continue to //! m...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
1
60
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2
/// next (LIFO). This is an optimization for message passing patterns and /// helps to reduce latency. lifo_slot: Option<Notified>, /// The worker-local run queue. run_queue: queue::Local<Arc<Worker>>, /// True if the worker is currently searching for more work. Searching /// involves attempti...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
41
100
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:3
/// /// The core is **not** placed back in the worker to avoid it from being /// stolen by a thread that was spawned as part of `block_in_place`. shutdown_workers: Mutex<Vec<(Box<Core>, Arc<Worker>)>>, } /// Used to communicate with a worker from other threads. struct Remote { /// Steal tasks from this...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
81
140
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4
type Notified = task::Notified<Arc<Worker>>; // Tracks thread-local state scoped_thread_local!(static CURRENT: Context); pub(super) fn create(size: usize, park: Parker) -> (Arc<Shared>, Launch) { let mut cores = vec![]; let mut remotes = vec![]; // Create the local queues for _ in 0..size { l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
121
180
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:5
let mut launch = Launch(vec![]); for (index, core) in cores.drain(..).enumerate() { launch.0.push(Arc::new(Worker { shared: shared.clone(), index, core: AtomicCell::new(Some(core)), })); } (shared, launch) } cfg_blocking! { use crate::runtime::enter...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
161
220
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
let mut had_entered = false; CURRENT.with(|maybe_cx| { match (crate::runtime::enter::context(), maybe_cx.is_some()) { (EnterContext::Entered { .. }, true) => { // We are on a thread pool runtime thread, so we just need to set up blocking. had...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
// The parker should be set here assert!(core.park.is_some()); // In order to block, the core must be sent to another thread for // execution. // // First, move the core back into the worker's shared core slot. cx.worker.core.set(core); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
runtime::spawn_blocking(move || run(worker)); } } } fn run(worker: Arc<Worker>) { // Acquire a core. If this fails, then another thread is running this // worker and there is nothing further to do. let core = match worker.core.take() { Some(core) => core, None => return, }; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
continue; } // There is no more **local** work to process, try to steal work // from other workers. if let Some(task) = core.steal_work(&self.worker) { core = self.run_task(task, core)?; } else { // Wait for work ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
/// Returns `true` if the transition happened. fn transition_from_parked(&mut self, worker: &Worker) -> bool { // If a task is in the lifo slot, then we must unpark regardless of // being notified if self.lifo_slot.is_some() { worker.shared.idle.unpark_worker_by_id(worker.index);...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
loop { self.drain_pending_drop(worker); if self.tasks.is_empty() { break; } // Wait until signalled park.park().expect("park failed"); } // Drain the queue while self.next_local_task().is_some() {} park.shutd...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
&self.shared.inject } /// Return a reference to this worker's remote data fn remote(&self) -> &Remote { &self.shared.remotes[self.index] } fn eq(&self, other: &Worker) -> bool { self.shared.ptr_eq(&other.shared) && self.index == other.index } } impl task::Schedule for Arc<Work...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
if let Some(core) = &mut *maybe_core { // Directly remove the task // // safety: the task is inserted in the list in `bind`. unsafe { let ptr = NonNull::from(task.header()); return core.tasks....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
641
700
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18
} fn schedule(&self, task: Notified) { self.shared.schedule(task, false); } fn yield_now(&self, task: Notified) { self.shared.schedule(task, true); } } impl Shared { pub(super) fn schedule(&self, task: Notified, is_yield: bool) { CURRENT.with(|maybe_cx| { if le...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
681
740
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:19
// Push to the LIFO slot let prev = core.lifo_slot.take(); let ret = prev.is_some(); if let Some(prev) = prev { core.run_queue.push_back(prev, &self.inject); } core.lifo_slot = Some(task); ret }; // Only notify i...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
721
780
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20
for remote in &self.remotes[..] { if !remote.steal.is_empty() { self.notify_parked(); return; } } if !self.inject.is_empty() { self.notify_parked(); } } fn transition_worker_from_searching(&self) { if self.idle...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/thread_pool/worker.rs
761
804
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20
for remote in &self.remotes[..] { if !remote.steal.is_empty() { self.notify_parked(); return; } } if !self.inject.is_empty() { self.notify_parked(); } } fn transition_worker_from_searching(&self) { if self.idle...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
c9f5bc29158a6f3a786e9d67df8da31524e8a9c3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/runtime/thread_pool/worker.rs
761
804
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:1
//! A scheduler is initialized with a fixed number of workers. Each worker is //! driven by a thread. Each worker has a "core" which contains data such as the //! run queue and other state. When `block_in_place` is called, the worker's //! "core" is handed off to a new thread allowing the scheduler to continue to //! m...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/runtime/thread_pool/worker.rs
1
60
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2
/// next (LIFO). This is an optimization for message passing patterns and /// helps to reduce latency. lifo_slot: Option<Notified>, /// The worker-local run queue. run_queue: queue::Local<Arc<Worker>>, /// True if the worker is currently searching for more work. Searching /// involves attempti...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
646fbae76535e397ef79dbcaacb945d4c829f666
github
async-runtime
https://github.com/tokio-rs/tokio/blob/646fbae76535e397ef79dbcaacb945d4c829f666/tokio/src/runtime/thread_pool/worker.rs
41
100
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
/// Returns `true` if the transition happened. fn transition_from_parked(&mut self, worker: &Worker) -> bool { // If a task is in the lifo slot, then we must unpark regardless of // being notified if self.lifo_slot.is_some() { worker.shared.idle.unpark_worker_by_id(worker.index);...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0366a3e6d1aa4e7bf4a1c717680dd0947589264b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0366a3e6d1aa4e7bf4a1c717680dd0947589264b/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
loop { self.drain_pending_drop(worker); if self.tasks.is_empty() { break; } // Wait until signalled park.park().expect("park failed"); } // Drain the queue while self.next_local_task().is_some() {} } fn drain...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0366a3e6d1aa4e7bf4a1c717680dd0947589264b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0366a3e6d1aa4e7bf4a1c717680dd0947589264b/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
/// Return a reference to this worker's remote data fn remote(&self) -> &Remote { &self.shared.remotes[self.index] } fn eq(&self, other: &Worker) -> bool { self.shared.ptr_eq(&other.shared) && self.index == other.index } } impl task::Schedule for Arc<Worker> { fn bind(task: Task) -...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0366a3e6d1aa4e7bf4a1c717680dd0947589264b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0366a3e6d1aa4e7bf4a1c717680dd0947589264b/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
// // safety: the task is inserted in the list in `bind`. unsafe { let ptr = NonNull::from(task.header()); return core.tasks.remove(ptr); } } } // Track the task to be rel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0366a3e6d1aa4e7bf4a1c717680dd0947589264b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0366a3e6d1aa4e7bf4a1c717680dd0947589264b/tokio/src/runtime/thread_pool/worker.rs
641
700
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18
fn schedule(&self, task: Notified) { self.shared.schedule(task, false); } fn yield_now(&self, task: Notified) { self.shared.schedule(task, true); } } impl Shared { pub(super) fn schedule(&self, task: Notified, is_yield: bool) { CURRENT.with(|maybe_cx| { if let Some(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0366a3e6d1aa4e7bf4a1c717680dd0947589264b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0366a3e6d1aa4e7bf4a1c717680dd0947589264b/tokio/src/runtime/thread_pool/worker.rs
681
740