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:5 | unpark: Unparker,
}
/// Thread-local context
struct Context {
/// Worker
worker: Arc<Worker>,
/// Core data
core: RefCell<Option<Box<Core>>>,
}
/// Starts the workers
pub(crate) struct Launch(Vec<Arc<Worker>>);
/// Running a task may consume the core. If the core is still available when
/// running ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6 | let (steal, run_queue) = queue::local();
let park = park.clone();
let unpark = park.unpark();
cores.push(Box::new(Core {
tick: 0,
lifo_slot: None,
run_queue,
is_searching: false,
is_shutdown: false,
park: Some(park),
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7 | (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) {
CURRENT.with(|maybe_cx| {
if let Some(cx) = maybe_cx {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8 | if allow_blocking {
had_entered = true;
return;
} else {
// This probably means we are on the basic_scheduler or in a
// LocalSet, where it is _not_ okay to block.
panic!("can call blocking only when runn... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9 | //
// Once the blocking task is done executing, we will attempt to
// steal the core back.
let worker = cx.worker.clone();
runtime::spawn_blocking(move || run(worker));
});
if had_entered {
// Unset the current task's budget. Blocking sections are not
// constrai... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10 | // 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 error. It only returns a `Result` to support
// using `?` to short circuit.
assert!(cx.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11 | core.pre_shutdown(&self.worker);
// Signal shutdown
self.worker.shared.shutdown(core);
Err(())
}
fn run_task(&self, task: Notified, mut core: Box<Core>) -> RunResult {
let task = self.worker.shared.owned.assert_owner(task);
// Make sure the worker is not in the **searc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12 | core.stats.incr_poll_count();
*self.core.borrow_mut() = Some(core);
let task = self.worker.shared.owned.assert_owner(task);
task.run();
} else {
// Not enough budget left to run the LIFO task, push it to
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13 | break;
}
}
}
if let Some(f) = &self.worker.shared.after_unpark {
f();
}
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.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14 | 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 == 0 {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15 | let target = &worker.shared.remotes[i];
if let Some(task) = target
.steal
.steal_into(&mut self.run_queue, &mut self.stats)
{
return Some(task);
}
}
// Fallback on checking the global queue
worker.shared.inject.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16 | // 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 | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17 | /// Runs maintenance work such as checking the pool's state.
fn maintenance(&mut self, worker: &Worker) {
self.stats.submit(&worker.shared.stats);
if !self.is_shutdown {
// Check if the scheduler has been shutdown
self.is_shutdown = worker.inject().is_closed();
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18 | fn release(&self, task: &Task) -> Option<Task> {
self.owned.remove(task)
}
fn schedule(&self, task: Notified) {
(**self).schedule(task, false);
}
fn yield_now(&self, task: Notified) {
(**self).schedule(task, true);
}
}
impl Shared {
pub(super) fn bind_new_task<T>(me: &... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:19 | return;
}
}
}
// 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 threa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:21 | /// Signals that a worker has observed the shutdown signal and has replaced
/// its core back into its handle.
///
/// If all workers have reached this point, the final cleanup is performed.
fn shutdown(&self, core: Box<Core>) {
let mut cores = self.shutdown_cores.lock();
cores.push(core... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/worker.rs | 801 | 830 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13 | break;
}
}
}
if let Some(f) = &self.worker.shared.after_unpark {
f();
}
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.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | e951d55720689ae5058d8af97a71a66d063f87cd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e951d55720689ae5058d8af97a71a66d063f87cd/tokio/src/runtime/thread_pool/worker.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14 | 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 == 0 {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | e951d55720689ae5058d8af97a71a66d063f87cd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e951d55720689ae5058d8af97a71a66d063f87cd/tokio/src/runtime/thread_pool/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15 | let target = &worker.shared.remotes[i];
if let Some(task) = target
.steal
.steal_into(&mut self.run_queue, &mut self.stats)
{
return Some(task);
}
}
// Fallback on checking the global queue
worker.shared.inject.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | e951d55720689ae5058d8af97a71a66d063f87cd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e951d55720689ae5058d8af97a71a66d063f87cd/tokio/src/runtime/thread_pool/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16 | // 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
.transition_worker_to_parked(worker.index, self.is_searching);
// The worker is ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | e951d55720689ae5058d8af97a71a66d063f87cd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e951d55720689ae5058d8af97a71a66d063f87cd/tokio/src/runtime/thread_pool/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17 | if !self.is_shutdown {
// Check if the scheduler has been shutdown
self.is_shutdown = worker.inject().is_closed();
}
}
/// Signals all tasks to shut down, and waits for them to complete. Must run
/// before we enter the single-threaded phase of shutdown processing.
fn pr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | e951d55720689ae5058d8af97a71a66d063f87cd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e951d55720689ae5058d8af97a71a66d063f87cd/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).schedule(task, false);
}
fn yield_now(&self, task: Notified) {
(**self).schedule(task, true);
}
}
impl Shared {
pub(super) fn bind_new_task<T>(me: &Arc<Self>, future: T) -> JoinHandle<T::Output>
where
T: Future + Send + 'static,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | e951d55720689ae5058d8af97a71a66d063f87cd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e951d55720689ae5058d8af97a71a66d063f87cd/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 always be pushed t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | e951d55720689ae5058d8af97a71a66d063f87cd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e951d55720689ae5058d8af97a71a66d063f87cd/tokio/src/runtime/thread_pool/worker.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:21 | fn shutdown(&self, core: Box<Core>) {
let mut cores = self.shutdown_cores.lock();
cores.push(core);
if cores.len() != self.remotes.len() {
return;
}
debug_assert!(self.owned.is_empty());
for mut core in cores.drain(..) {
core.shutdown();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | e951d55720689ae5058d8af97a71a66d063f87cd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e951d55720689ae5058d8af97a71a66d063f87cd/tokio/src/runtime/thread_pool/worker.rs | 801 | 826 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2 | //! inject queue.
//!
//! The first case can only happen if the OwnedTasks::bind call happens before
//! or during step 1 of shutdown. In this case, the runtime will clean up the
//! task in step 3 of shutdown.
//!
//! In the latter case, the task was not spawned and the task is immediately
//! cancelled by the spaw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:3 | /// Index holding this worker's remote state
index: usize,
/// Used to hand-off a worker's core to another thread.
core: AtomicCell<Core>,
}
/// Core data
struct Core {
/// Used to schedule bookkeeping tasks every so often.
tick: u8,
/// When a task is scheduled from a worker, it is stored in... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4 | }
/// State shared across all workers
pub(super) struct Shared {
/// Per-worker remote state. All other workers have access to this and is
/// how they communicate between each other.
remotes: Box<[Remote]>,
/// Submits work to the scheduler while **not** currently on a worker thread.
inject: Inje... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:5 | }
/// Thread-local context
struct Context {
/// Worker
worker: Arc<Worker>,
/// Core data
core: RefCell<Option<Box<Core>>>,
}
/// Starts the workers
pub(crate) struct Launch(Vec<Arc<Worker>>);
/// Running a task may consume the core. If the core is still available when
/// running the task completes... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6 | let park = park.clone();
let unpark = park.unpark();
cores.push(Box::new(Core {
tick: 0,
lifo_slot: None,
run_queue,
is_searching: false,
is_shutdown: false,
park: Some(park),
stats: WorkerStatsBatcher::new(i),
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7 | }
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) {
CURRENT.with(|maybe_cx| {
if let Some(cx) = maybe_cx {
let core ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8 | had_entered = true;
return;
} else {
// This probably means we are on the basic_scheduler or in a
// LocalSet, where it is _not_ okay to block.
panic!("can call blocking only when running on the multi-threaded runtime");
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9 | // Once the blocking task is done executing, we will attempt to
// steal the core back.
let worker = cx.worker.clone();
runtime::spawn_blocking(move || run(worker));
});
if had_entered {
// Unset the current task's budget. Blocking sections are not
// constrained by task... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10 | let cx = Context {
worker,
core: RefCell::new(None),
};
let _enter = crate::runtime::enter(true);
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());
});
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11 | // Signal shutdown
self.worker.shared.shutdown(core);
Err(())
}
fn run_task(&self, task: Notified, mut core: Box<Core>) -> RunResult {
let task = self.worker.shared.owned.assert_owner(task);
// Make sure the worker is not in the **searching** state. This enables
// anot... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12 | *self.core.borrow_mut() = Some(core);
let task = self.worker.shared.owned.assert_owner(task);
task.run();
} else {
// Not enough budget left to run the LIFO task, push it to
// the back of the queue and return.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13 | }
}
}
if let Some(f) = &self.worker.shared.after_unpark {
f();
}
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 mis... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14 | }
}
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 | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15 | if let Some(task) = target
.steal
.steal_into(&mut self.run_queue, &mut self.stats)
{
return Some(task);
}
}
// Fallback on checking the global queue
worker.shared.inject.pop()
}
fn transition_to_searching(&mut sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16 | // between the last work scan and transitioning out of searching.
let is_last_searcher = worker
.shared
.idle
.transition_worker_to_parked(worker.index, self.is_searching);
// The worker is no longer searching. Setting this is the local cache
// only.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18 | (**self).schedule(task, false);
}
fn yield_now(&self, task: Notified) {
(**self).schedule(task, true);
}
}
impl Shared {
pub(super) fn bind_new_task<T>(me: &Arc<Self>, future: T) -> JoinHandle<T::Output>
where
T: Future + Send + 'static,
T::Output: Send + 'static,
{
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/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 always be pushed t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20 | }
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 | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:21 | let mut cores = self.shutdown_cores.lock();
cores.push(core);
if cores.len() != self.remotes.len() {
return;
}
debug_assert!(self.owned.is_empty());
for mut core in cores.drain(..) {
core.shutdown();
}
// Drain the injection queue
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 867f137dc98ec41e7480d7f56158c3e7758b1a7e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/867f137dc98ec41e7480d7f56158c3e7758b1a7e/tokio/src/runtime/thread_pool/worker.rs | 801 | 825 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:3 | /// Index holding this worker's remote state
index: usize,
/// Used to hand-off a worker's core to another thread.
core: AtomicCell<Core>,
}
/// Core data
struct Core {
/// Used to schedule bookkeeping tasks every so often.
tick: u8,
/// When a task is scheduled from a worker, it is stored in... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 957ed3eac07222a2d86ccfde8f29f29599f6f563 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/957ed3eac07222a2d86ccfde8f29f29599f6f563/tokio/src/runtime/thread_pool/worker.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4 | }
/// State shared across all workers
pub(super) struct Shared {
/// Per-worker remote state. All other workers have access to this and is
/// how they communicate between each other.
remotes: Box<[Remote]>,
/// Submit work to the scheduler while **not** currently on a worker thread.
inject: Injec... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 957ed3eac07222a2d86ccfde8f29f29599f6f563 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/957ed3eac07222a2d86ccfde8f29f29599f6f563/tokio/src/runtime/thread_pool/worker.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15 | if let Some(task) = target
.steal
.steal_into(&mut self.run_queue, &mut self.stats)
{
return Some(task);
}
}
// Fallback on checking the global queue
worker.shared.inject.pop()
}
fn transition_to_searching(&mut sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 957ed3eac07222a2d86ccfde8f29f29599f6f563 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/957ed3eac07222a2d86ccfde8f29f29599f6f563/tokio/src/runtime/thread_pool/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16 | // between the last work scan and transitioning out of searching.
let is_last_searcher = worker
.shared
.idle
.transition_worker_to_parked(worker.index, self.is_searching);
// The worker is no longer searching. Setting this is the local cache
// only.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 957ed3eac07222a2d86ccfde8f29f29599f6f563 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/957ed3eac07222a2d86ccfde8f29f29599f6f563/tokio/src/runtime/thread_pool/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17 | if !self.is_shutdown {
// Check if the scheduler has been shutdown
self.is_shutdown = worker.inject().is_closed();
}
}
/// Signals all tasks to shut down, and waits for them to complete. Must run
/// before we enter the single-threaded phase of shutdown processing.
fn pr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 957ed3eac07222a2d86ccfde8f29f29599f6f563 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/957ed3eac07222a2d86ccfde8f29f29599f6f563/tokio/src/runtime/thread_pool/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2 | //! inject queue.
//!
//! The first case can only happen if the OwnedTasks::bind call happens before
//! or during step 1 of shutdown. In this case, the runtime will clean up the
//! task in step 3 of shutdown.
//!
//! In the latter case, the task was not spawned and the task is immediately
//! cancelled by the spaw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4 | }
/// State shared across all workers
pub(super) struct Shared {
/// Per-worker remote state. All other workers have access to this and is
/// how they communicate between each other.
remotes: Box<[Remote]>,
/// Submit work to the scheduler while **not** currently on a worker thread.
inject: Injec... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:5 | worker: Arc<Worker>,
/// Core data
core: RefCell<Option<Box<Core>>>,
}
/// Starts the workers
pub(crate) struct Launch(Vec<Arc<Worker>>);
/// Running a task may consume the core. If the core is still available when
/// running the task completes, it is returned. Otherwise, the worker will need
/// to stop pr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6 | park: Some(park),
stats: WorkerStatsBatcher::new(i),
rand: FastRand::new(seed()),
}));
remotes.push(Remote { steal, unpark });
}
let shared = Arc::new(Shared {
remotes: remotes.into_boxed_slice(),
inject: Inject::new(),
idle: Idle::new(size),
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7 | if let Some(cx) = maybe_cx {
let core = cx.worker.core.take();
let mut cx_core = cx.core.borrow_mut();
assert!(cx_core.is_none());
*cx_core = core;
// Reset the task budget as we are re-entering the
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8 | }
(EnterContext::NotEntered, false) => {
// We are outside of the tokio runtime, so blocking is fine.
// We can also skip all of the thread pool blocking setup steps.
return;
}
}
let cx = maybe_cx.expect("no .is_some() == false cas... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9 | } 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(crate) fn launch(mut self) {
for worker in self.0... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10 | }
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 work available to the current worker.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11 | // Make the core available to the runtime context
core.stats.incr_poll_count();
*self.core.borrow_mut() = Some(core);
// Run the task
coop::budget(|| {
task.run();
// As long as there is budget remaining and a task exists in the
// `lifo_slot`, then ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12 | fn maintenance(&self, mut core: Box<Core>) -> Box<Core> {
if core.tick % GLOBAL_POLL_INTERVAL == 0 {
// Call `park` with a 0 timeout. This enables the I/O driver, timer, ...
// to run without actually putting the thread to sleep.
core = self.park_timeout(core, Some(Duration::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13 | // Park thread
if let Some(timeout) = duration {
park.park_timeout(timeout).expect("park failed");
} else {
park.park().expect("park failed");
}
// Remove `core` from context
core = self.core.borrow_mut().take().expect("core missing");
// Place `... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14 | self.lifo_slot.take().or_else(|| self.run_queue.pop())
}
fn steal_work(&mut self, worker: &Worker) -> Option<Notified> {
if !self.transition_to_searching(worker) {
return None;
}
let num = worker.shared.remotes.len();
// Start from a random worker
let start ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15 | fn transition_from_searching(&mut self, worker: &Worker) {
if !self.is_searching {
return;
}
self.is_searching = false;
worker.shared.transition_worker_from_searching();
}
/// Prepare the worker state for parking
fn transition_to_parked(&mut self, worker: &Worke... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16 | return false;
}
// When unparked, the worker is in the searching state.
self.is_searching = true;
true
}
/// Runs maintenance work such as checking the pool's state.
fn maintenance(&mut self, worker: &Worker) {
self.stats.submit(&worker.shared.stats);
if !s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17 | /// Returns a reference to the scheduler's injection queue
fn inject(&self) -> &Inject<Arc<Shared>> {
&self.shared.inject
}
}
impl task::Schedule for Arc<Shared> {
fn release(&self, task: &Task) -> Option<Task> {
self.owned.remove(task)
}
fn schedule(&self, task: Notified) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18 | 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 holds a core
if let Some(core) = cx.core.borrow_mut()... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20 | 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 the shutdown signal and has replaced
/// its core... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | 98578a6f4a494e709f00018b1cd5b0e3dd9a0f72 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/98578a6f4a494e709f00018b1cd5b0e3dd9a0f72/tokio/src/runtime/thread_pool/worker.rs | 761 | 797 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2 | //! inject queue.
//!
//! The first case can only happen if the OwnedTasks::bind call happens before
//! or during step 1 of shutdown. In this case, the runtime will clean up the
//! task in step 3 of shutdown.
//!
//! In the latter case, the task was not spawned and the task is immediately
//! cancelled by the spaw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:3 | index: usize,
/// Used to hand-off a worker's core to another thread.
core: AtomicCell<Core>,
}
/// Core data
struct Core {
/// Used to schedule bookkeeping tasks every so often.
tick: u8,
/// When a task is scheduled from a worker, it is stored in this slot. The
/// worker will check this sl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4 | /// Per-worker remote state. All other workers have access to this and is
/// how they communicate between each other.
remotes: Box<[Remote]>,
/// Submit work to the scheduler while **not** currently on a worker thread.
inject: Inject<Arc<Shared>>,
/// Coordinates idle workers
idle: Idle,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:5 | pub(crate) struct Launch(Vec<Arc<Worker>>);
/// Running a task may consume the core. If the core is still available when
/// running the task completes, it is returned. Otherwise, the worker will need
/// to stop processing.
type RunResult = Result<Box<Core>, ()>;
/// A task handle
type Task = task::Task<Arc<Shared>>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6 | let shared = Arc::new(Shared {
remotes: remotes.into_boxed_slice(),
inject: Inject::new(),
idle: Idle::new(size),
owned: OwnedTasks::new(),
shutdown_cores: Mutex::new(vec![]),
});
let mut launch = Launch(vec![]);
for (index, core) in cores.drain(..).enumerate() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7 | }
});
}
}
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
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8 | // Get the worker core. If none is set, then blocking is fine!
let core = match cx.core.borrow_mut().take() {
Some(core) => core,
None => return,
};
// The parker should be set here
assert!(core.park.is_some());
// In order to block, the core must be sen... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9 | const GLOBAL_POLL_INTERVAL: u8 = 61;
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
// wo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10 | core = self.maintenance(core);
// 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 s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11 | // `lifo_slot`, then keep running.
loop {
// Check if we still have the core. If not, the core was stolen
// by another worker.
let mut core = match self.core.borrow_mut().take() {
Some(core) => core,
None => return Err(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12 | core
}
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.tr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13 | // If there are tasks available to steal, notify a worker
if core.run_queue.is_stealable() {
self.worker.shared.notify_parked();
}
core
}
}
impl Core {
/// Increment the tick
fn tick(&mut self) {
self.tick = self.tick.wrapping_add(1);
}
/// Return the n... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14 | // Don't steal from ourself! We know we don't have work.
if i == worker.index {
continue;
}
let target = &worker.shared.remotes[i];
if let Some(task) = target.steal.steal_into(&mut self.run_queue) {
return Some(task);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15 | .transition_worker_to_parked(worker.index, self.is_searching);
// The worker is no longer searching. Setting this is the local cache
// only.
self.is_searching = false;
if is_last_searcher {
worker.shared.notify_if_work_pending();
}
}
/// Returns `true` if ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16 | fn pre_shutdown(&mut self, worker: &Worker) {
// Signal to all tasks to shut down.
worker.shared.owned.close_and_shutdown_all();
}
/// Shutdown the core
fn shutdown(&mut self) {
// Take the core
let mut park = self.park.take().expect("park missing");
// Drain the qu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17 | where
T: Future + Send + 'static,
T::Output: Send + 'static,
{
let (handle, notified) = me.owned.bind(future, me.clone());
if let Some(notified) = notified {
me.schedule(notified, false);
}
handle
}
pub(super) fn schedule(&self, task: Notified, ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18 | } 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 | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:19 | 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 | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 721 | 771 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20 | //
// We already shut down every task, so we can simply drop the tasks.
while let Some(task) = self.inject.pop() {
drop(task);
}
}
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 | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/thread_pool/worker.rs | 761 | 771 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15 | .transition_worker_to_parked(worker.index, self.is_searching);
// The worker is no longer searching. Setting this is the local cache
// only.
self.is_searching = false;
if is_last_searcher {
worker.shared.notify_if_work_pending();
}
}
/// Returns `true` if ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | f2a06bff1be147a72d40cb01d8bb621fbdc242fc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f2a06bff1be147a72d40cb01d8bb621fbdc242fc/tokio/src/runtime/thread_pool/worker.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16 | fn pre_shutdown(&mut self, worker: &Worker) {
// The OwnedTasks was closed in Shared::close.
debug_assert!(worker.shared.owned.is_closed());
// Signal to all tasks to shut down.
while let Some(header) = worker.shared.owned.pop_back() {
header.shutdown();
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | f2a06bff1be147a72d40cb01d8bb621fbdc242fc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f2a06bff1be147a72d40cb01d8bb621fbdc242fc/tokio/src/runtime/thread_pool/worker.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17 | }
}
impl Shared {
pub(super) fn bind_new_task<T>(me: &Arc<Self>, future: T) -> JoinHandle<T::Output>
where
T: Future + Send + 'static,
T::Output: Send + 'static,
{
let (handle, notified) = me.owned.bind(future, me.clone());
if let Some(notified) = notified {
me.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | f2a06bff1be147a72d40cb01d8bb621fbdc242fc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f2a06bff1be147a72d40cb01d8bb621fbdc242fc/tokio/src/runtime/thread_pool/worker.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18 | // tasks to be executed. If **not** a yield, then there is more
// flexibility and the task may go to the front of the queue.
let should_notify = if is_yield {
core.run_queue.push_back(task, &self.inject);
true
} else {
// Push to the LIFO slot
let... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | f2a06bff1be147a72d40cb01d8bb621fbdc242fc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f2a06bff1be147a72d40cb01d8bb621fbdc242fc/tokio/src/runtime/thread_pool/worker.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:19 | fn notify_all(&self) {
for remote in &self.remotes[..] {
remote.unpark.unpark();
}
}
fn notify_if_work_pending(&self) {
for remote in &self.remotes[..] {
if !remote.steal.is_empty() {
self.notify_parked();
return;
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | f2a06bff1be147a72d40cb01d8bb621fbdc242fc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f2a06bff1be147a72d40cb01d8bb621fbdc242fc/tokio/src/runtime/thread_pool/worker.rs | 721 | 777 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:20 | for mut core in cores.drain(..) {
core.shutdown();
}
// Drain the injection queue
//
// We already shut down every task, so we can simply drop the tasks.
while let Some(task) = self.inject.pop() {
drop(task);
}
}
fn ptr_eq(&self, other: &... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/worker.rs | MIT | f2a06bff1be147a72d40cb01d8bb621fbdc242fc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f2a06bff1be147a72d40cb01d8bb621fbdc242fc/tokio/src/runtime/thread_pool/worker.rs | 761 | 777 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10 | core = self.maintenance(core);
// 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 s... | 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 | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11 | // Check if we still have the core. If not, the core was stolen
// by another worker.
let mut core = match self.core.borrow_mut().take() {
Some(core) => core,
None => return Err(()),
};
// Check for a task in the LI... | 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 | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12 | 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 | 2087f3e0ebb08d633d59c5f964b3901e68b3c038 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/tokio/src/runtime/thread_pool/worker.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13 | }
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 | 2087f3e0ebb08d633d59c5f964b3901e68b3c038 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/tokio/src/runtime/thread_pool/worker.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14 | }
let target = &worker.shared.remotes[i];
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... | 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 | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15 | // only.
self.is_searching = false;
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 un... | 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 | 561 | 620 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16 | // Signal to all tasks to shut down.
while let Some(header) = worker.shared.owned.pop_back() {
header.shutdown();
}
}
/// Shutdown the core
fn shutdown(&mut self) {
// Take the core
let mut park = self.park.take().expect("park missing");
// Drain the que... | 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 | 601 | 660 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17 | impl Shared {
pub(super) fn bind_new_task<T>(me: &Arc<Self>, future: T) -> JoinHandle<T::Output>
where
T: Future + Send + 'static,
T::Output: Send + 'static,
{
let (handle, notified) = me.owned.bind(future, me.clone());
if let Some(notified) = notified {
me.sched... | 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 | 641 | 700 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:18 | let should_notify = if is_yield {
core.run_queue.push_back(task, &self.inject);
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.pu... | 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 | 681 | 740 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:19 | remote.unpark.unpark();
}
}
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()... | 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 | 721 | 773 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.