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:19
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 if not currently parked. If `park` is `None`, then the // scheduling is from...
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
721
780
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20
self.notify_parked(); 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. Beca...
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
761
802
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
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
161
220
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
let mut had_core = false; 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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/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(c...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
impl Launch { pub(crate) fn launch(mut self) { for worker in self.0.drain(..) { 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 d...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
// First, check work available to the current worker. if let Some(task) = core.next_task(&self.worker) { core = self.run_task(task, core)?; continue; } // There is no more **local** work to process, try to steal work // from other workers....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
Some(core) => core, None => return Err(()), }; // Check for a task in the LIFO slot let task = match core.lifo_slot.take() { Some(task) => task, None => return Ok(core), }; if co...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11
while !core.is_shutdown { core = self.park_timeout(core, None); // Run regularly scheduled maintenance core.maintenance(&self.worker); if core.transition_from_parked(&self.worker) { return core; } } core } fn park_ti...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
401
460
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12
} } impl Core { /// 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 { wor...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
441
500
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13
if let Some(task) = target.steal.steal_into(&mut self.run_queue) { return Some(task); } } // Fallback on checking the global queue worker.shared.inject.pop() } fn transition_to_searching(&mut self, worker: &Worker) -> bool { if !self.is_searching { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
481
540
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
if is_last_searcher { worker.shared.notify_if_work_pending(); } } /// 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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
// Signal to all tasks to shut down. for header in self.tasks.iter() { header.shutdown(); } loop { self.drain_pending_drop(worker); if self.tasks.is_empty() { break; } // Wait until signalled park.park().e...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
/// 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] } fn eq(&self, other: &Worker) -...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
let mut maybe_core = cx.core.borrow_mut(); 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::fro...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
641
700
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18
None }) } 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|...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
681
740
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:19
true } else { // 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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
721
780
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20
fn notify_if_work_pending(&self) { 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_f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fc63fa2606e715fd4fef132a1bcfaa18dafdbc6e/tokio/src/runtime/thread_pool/worker.rs
761
806
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
4010335c84517571e9b2d13f66f7c72170493622
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4010335c84517571e9b2d13f66f7c72170493622/tokio/src/runtime/thread_pool/worker.rs
161
220
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
let mut had_core = 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. } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
4010335c84517571e9b2d13f66f7c72170493622
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4010335c84517571e9b2d13f66f7c72170493622/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
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); had_core = true; // Next, clon...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
4010335c84517571e9b2d13f66f7c72170493622
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4010335c84517571e9b2d13f66f7c72170493622/tokio/src/runtime/thread_pool/worker.rs
241
300
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
bff21aba6c1568f260fdf48d2eb3c0566e293f5a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bff21aba6c1568f260fdf48d2eb3c0566e293f5a/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 let Some(_) = self.next_local_task() {} } fn d...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
bff21aba6c1568f260fdf48d2eb3c0566e293f5a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bff21aba6c1568f260fdf48d2eb3c0566e293f5a/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20
self.notify_parked(); 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. Beca...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
bff21aba6c1568f260fdf48d2eb3c0566e293f5a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bff21aba6c1568f260fdf48d2eb3c0566e293f5a/tokio/src/runtime/thread_pool/worker.rs
761
802
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
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/runtime/thread_pool/worker.rs
1
60
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2
/// 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 attempting to steal from other workers. is_searching: bool, /// True if the s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/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 worker....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/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
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/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
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/runtime/thread_pool/worker.rs
161
220
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
} }); } } let mut had_core = 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 ju...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
crate::coop::stop(); core }, None => return, }; // 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. // ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
// First, check work available to the current worker. if let Some(task) = core.next_task(&self.worker) { core = self.run_task(task, core)?; continue; } // There is no more **local** work to process, try to steal work // from other workers....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
Some(core) => core, None => return Err(()), }; // Check for a task in the LIFO slot let task = match core.lifo_slot.take() { Some(task) => task, None => return Ok(core), }; if cr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
if is_last_searcher { worker.shared.notify_if_work_pending(); } } /// 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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
// Signal to all tasks to shut down. for header in self.tasks.iter() { header.shutdown(); } loop { self.drain_pending_drop(worker); if self.tasks.is_empty() { break; } // Wait until signalled park.park().e...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20
fn notify_if_work_pending(&self) { 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_f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
282b00cbe888a96669877ce70662fba87e8c0e3c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/282b00cbe888a96669877ce70662fba87e8c0e3c/tokio/src/runtime/thread_pool/worker.rs
761
806
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
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/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! { pub(crate) fn block_in_pl...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
161
220
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
} } let mut had_core = false; CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("can call blocking only when running in a spawned task on the multi-threaded runtime"); // Get the worker core. If none is set, then blocking is fine! let core = match cx.core.b...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
crate::runtime::enter::exit(f) } else { f() } } } /// After how many ticks is the global queue polled. This helps to ensure /// fairness. /// /// The number is fairly arbitrary. I believe this value was copied from golang. const GLOBAL_POLL_INTERVAL: u8 = 61; impl Launch { pub(crat...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
assert!(cx.run(core).is_err()); }); } impl Context { fn run(&self, mut core: Box<Core>) -> RunResult { while !core.is_shutdown { // Increment the tick core.tick(); // Run maintenance, if needed core = self.maintenance(core); // First, check ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
*self.core.borrow_mut() = Some(core); // Run the task crate::coop::budget(|| { task.run(); // As long as there is budget remaining and a task exists in the // `lifo_slot`, then keep running. loop { // Check if we still have the core. If n...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
core = self.park_timeout(core, Some(Duration::from_millis(0))); // Run regularly scheduled maintenance core.maintenance(&self.worker); } core } fn park(&self, mut core: Box<Core>) -> Box<Core> { core.transition_to_parked(&self.worker); while !core.is_s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11
// Remove `core` from context core = self.core.borrow_mut().take().expect("core missing"); // Place `park` back in `core` core.park = Some(park); // If there are tasks available to steal, notify a worker if core.run_queue.is_stealable() { self.worker.shared.notify_p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
401
460
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12
// Start from a random worker let start = self.rand.fastrand_n(num as u32) as usize; for i in 0..num { let i = (start + i) % num; // Don't steal from ourself! We know we don't have work. if i == worker.index { continue; } let...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
441
500
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13
// When the final worker transitions **out** of searching to parked, it // must check all the queues one last time in case work materialized // between the last work scan and transitioning out of searching. let is_last_searcher = worker .shared .idle .transiti...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
481
540
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
if !self.is_shutdown { // Check if the scheduler has been shutdown self.is_shutdown = worker.inject().is_closed(); } } // Shutdown the core fn shutdown(&mut self, worker: &Worker) { // Take the core let mut park = self.park.take().expect("park missing"); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
// is pushed into `pending_drop`, the ref-inc is skipped, so we must // not ref-dec here. // // See `bind` and `release` implementations. unsafe { self.tasks.remove(task.header().into()); } } } } impl Worker { /// Returns a ref...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
// Return a clone of the worker cx.worker.clone() }) } fn release(&self, task: &Task) -> Option<Task> { use std::ptr::NonNull; CURRENT.with(|maybe_cx| { let cx = maybe_cx.expect("scheduler context missing"); if self.eq(&cx.worker) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
if cx.core.borrow().is_some() { return None; } // The worker core has been handed off to another thread. In the // event that the scheduler is currently shutting down, the thread // that owns the task may be waiting on the release to complete ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
641
700
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18
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 always be pushed to the back of the queue, enabling other ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
681
740
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:19
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 notify_if_work_pending(&self) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
721
778
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20
workers.push((core, worker)); if workers.len() != self.remotes.len() { return; } for (mut core, worker) in workers.drain(..) { core.shutdown(&worker); } // Drain the injection queue while let Some(_) = self.inject.pop() {} } fn ptr_eq(&...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
67c4cc03919a58076c139f0930f28c3c41dad1e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/67c4cc03919a58076c139f0930f28c3c41dad1e5/tokio/src/runtime/thread_pool/worker.rs
761
778
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
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/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! { pub(crate) fn block_in_pl...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/thread_pool/worker.rs
161
220
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
crate::coop::stop(); core }, None => return, }; // 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. // ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
} } } 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
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
} // 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(cor...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
let task = match core.lifo_slot.take() { Some(task) => task, None => return Ok(core), }; if crate::coop::has_budget_remaining() { // Run the LIFO task, then loop *self.core.borrow_mut() = Some(core); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
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 = core.park.take().expect("park missing"); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11
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_else(|| self.next_local_ta...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/thread_pool/worker.rs
401
460
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12
// 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
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/thread_pool/worker.rs
441
500
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13
/// 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
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/thread_pool/worker.rs
481
540
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
loop { self.drain_pending_drop(worker); if self.tasks.is_empty() { break; } // Wait until signalled park.park().expect("park failed"); } // Drain the queue while let Some(_) = self.next_local_task() {} } fn d...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:19
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
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/thread_pool/worker.rs
721
761
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
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
1
60
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2
/// involves attempting to steal from other workers. is_searching: bool, /// True if the scheduler is being shutdown is_shutdown: bool, /// Tasks owned by the core tasks: LinkedList<Task>, /// Parker /// /// Stored in an `Option` as the parker is added / removed to make the /// bo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
41
100
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:3
/// Steal tasks from this worker. steal: queue::Steal<Arc<Worker>>, /// Transfers tasks to be released. Any worker pushes tasks, only the owning /// worker pops. pending_drop: task::TransferStack<Arc<Worker>>, /// Unparks the associated worker thread unpark: Unparker, } /// Thread-local conte...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
81
140
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4
// Create the local queues for _ in 0..size { let (steal, run_queue) = queue::local(); let park = park.clone(); let unpark = park.unpark(); cores.push(Box::new(Core { tick: 0, run_queue, is_searching: false, is_shutdown: false, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
121
180
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:5
} (shared, launch) } cfg_blocking! { pub(crate) fn block_in_place<F, R>(f: F) -> R where F: FnOnce() -> R, { // Try to steal the worker core back struct Reset; impl Drop for Reset { fn drop(&mut self) { CURRENT.with(|maybe_cx| { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
161
220
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
// 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 handle and send it to a new thread for // proce...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
Some(core) => core, None => return, }; // Set the worker context. let cx = Context { worker, core: RefCell::new(None), }; let _enter = crate::runtime::enter(); CURRENT.set(&cx, || { // This should always be an error. It only returns a `Result` to support ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
core = self.park(core); } } // Signal shutdown self.worker.shared.shutdown(core, self.worker.clone()); Err(()) } fn run_task(&self, task: Notified, mut core: Box<Core>) -> RunResult { // Make sure thew orker is not in the **searching** state. This enables ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
fn park(&self, mut core: Box<Core>) -> Box<Core> { core.transition_to_parked(&self.worker); while !core.is_shutdown { core = self.park_timeout(core, None); // Run regularly scheduled maintenance core.maintenance(&self.worker); if core.transition_from_pa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
} core } } impl Core { /// 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 ==...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11
return Some(task); } } // 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();...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
401
460
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12
worker.shared.notify_if_work_pending(); } } /// Returns `true` if the transition happened. fn transition_from_parked(&mut self, worker: &Worker) -> bool { // If there is a non-stealable task, then we must unpark regardless of // being notified if self.run_queue.has_unstealab...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
441
500
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13
for header in self.tasks.iter() { header.shutdown(); } loop { self.drain_pending_drop(worker); if self.tasks.is_empty() { break; } // Wait until signalled park.park().expect("park failed"); } // D...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
481
540
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
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] } fn eq(&self, other: &Worker) -> bool { self.shared.ptr_eq(&other.shared) && self.inde...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
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
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
}) } 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| { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
} else { core.run_queue.push(task, &self.inject) }; // 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 sh...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
641
700
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18
} } 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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1cb1e291c10adf6b4e530cb1475b95ba10fa615f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1cb1e291c10adf6b4e530cb1475b95ba10fa615f/tokio/src/runtime/thread_pool/worker.rs
681
715
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
06a4d895ec8787386058a24b422dfa9a8514bc8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/06a4d895ec8787386058a24b422dfa9a8514bc8e/tokio/src/runtime/thread_pool/worker.rs
1
60
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:5
} (shared, launch) } cfg_blocking! { pub(crate) fn block_in_place<F, R>(f: F) -> R where F: FnOnce() -> R, { // Try to steal the worker core back struct Reset; impl Drop for Reset { fn drop(&mut self) { CURRENT.with(|maybe_cx| { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
161
220
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
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. let worker = cx.worker.clone(); runtim...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
let cx = Context { worker, core: RefCell::new(None), }; let _enter = crate::runtime::enter(); CURRENT.set(&cx, || { // This should always be an error. It only returns a `Result` to support // using `?` to short circuit. assert!(cx.run(core).is_err()); }); } imp...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
self.worker.shared.shutdown(core, self.worker.clone()); Err(()) } fn run_task(&self, task: Notified, mut core: Box<Core>) -> RunResult { // Make sure thew orker is not in the **searching** state. This enables // another idle worker to try to steal work. core.transition_from_sear...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
// Run regularly scheduled maintenance 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> { // T...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
impl Core { /// 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.i...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11
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 transition_from_searching(&mut self, worker: &Wor...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
401
460
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12
fn transition_from_parked(&mut self, worker: &Worker) -> bool { // If there is a non-stealable task, then we must unpark regardless of // being notified if self.run_queue.has_unstealable() { worker.shared.idle.unpark_worker_by_id(worker.index); self.is_searching = true; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
441
500
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13
self.drain_pending_drop(worker); if self.tasks.is_empty() { break; } // Wait until signalled park.park().expect("park failed"); } // Drain the queue while let Some(_) = self.run_queue.pop() {} } fn drain_pending_drop(&mu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
481
540
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
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) -> Arc<Worker> { CURRENT.with(|maybe_cx| { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
unsafe { let ptr = NonNull::from(task.header()); return core.tasks.remove(ptr); } } } // Track the task to be released by the worker that owns it // // Safety: We get a new handle without...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
} 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 the task is part of the **current** sc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
// 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(); } } pub(super) fn close(&self) { if self.inject.close() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
641
700
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18
// 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 the shutdown signal and has replaced /// its core back into its handle. /// /// If all workers have rea...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
a78b1c65ccfb9692ca5d3ed8ddde934f40091d83
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/worker.rs
681
710
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:1
use crate::loom::cell::CausalCell; use crate::loom::sync::Arc; use crate::park::Park; use crate::runtime; use crate::runtime::park::Parker; use crate::runtime::thread_pool::{current, slice, Owned, Shared}; use crate::task::Task; use std::cell::Cell; use std::marker::PhantomData; use std::sync::atomic::Ordering::Relaxe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
55b5e1b6adcc3f85a35d16444e496b203648c99d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/55b5e1b6adcc3f85a35d16444e496b203648c99d/tokio/src/runtime/thread_pool/worker.rs
1
60
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2
} pub(crate) struct Worker { /// Parks the thread. Requires the calling worker to have obtained unique /// access via the generation synchronization action. inner: Arc<Inner>, /// Scheduler slices slices: Arc<slice::Set>, /// Slice assigned to this worker index: usize, /// Worker gen...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
55b5e1b6adcc3f85a35d16444e496b203648c99d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/55b5e1b6adcc3f85a35d16444e496b203648c99d/tokio/src/runtime/thread_pool/worker.rs
41
100