mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-18 00:00:09 +02:00
committed by
Toby Lawrence
parent
7dc6404726
commit
82c5baa09b
@@ -103,7 +103,7 @@ extern crate log;
|
||||
//
|
||||
// ## Sleeping workers
|
||||
//
|
||||
// Sleeping workers are tracked using a [treiber stack]. This results in the
|
||||
// Sleeping workers are tracked using a [Treiber stack]. This results in the
|
||||
// thread that most recently went to sleep getting woken up first. When the pool
|
||||
// is not under load, this helps threads shutdown faster.
|
||||
//
|
||||
@@ -137,7 +137,7 @@ extern crate log;
|
||||
// Also, whenever a worker is woken up via a signal and it does find work, it,
|
||||
// in turn, will try to wake up a new worker.
|
||||
//
|
||||
// [treiber stack]: https://en.wikipedia.org/wiki/Treiber_Stack
|
||||
// [Treiber stack]: https://en.wikipedia.org/wiki/Treiber_Stack
|
||||
|
||||
pub mod park;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ pub(crate) struct Backup {
|
||||
/// * If the thread is running
|
||||
state: AtomicUsize,
|
||||
|
||||
/// Next entry in the treiber stack.
|
||||
/// Next entry in the Treiber stack.
|
||||
next_sleeper: UnsafeCell<BackupId>,
|
||||
|
||||
/// Used to put the thread to sleep
|
||||
|
||||
@@ -22,7 +22,7 @@ pub(crate) const EMPTY: BackupId = BackupId(MAX_BACKUP);
|
||||
/// Used to mark the stack as terminated
|
||||
pub(crate) const TERMINATED: BackupId = BackupId(EMPTY.0 + 1);
|
||||
|
||||
/// How many bits the treiber ABA guard is offset by
|
||||
/// How many bits the Treiber ABA guard is offset by
|
||||
const ABA_GUARD_SHIFT: usize = 16;
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
@@ -165,7 +165,7 @@ impl State {
|
||||
fn set_head(&mut self, val: BackupId) {
|
||||
let val = val.0;
|
||||
|
||||
// The ABA guard protects against the ABA problem w/ treiber stacks
|
||||
// The ABA guard protects against the ABA problem w/ Treiber stacks
|
||||
let aba_guard = ((self.0 >> ABA_GUARD_SHIFT) + 1) & ABA_GUARD_MASK;
|
||||
|
||||
self.0 = (aba_guard << ABA_GUARD_SHIFT) | val;
|
||||
|
||||
@@ -14,7 +14,7 @@ use std::thread;
|
||||
/// Manages the state around entering a blocking section and tasks that are
|
||||
/// queued pending the ability to block.
|
||||
///
|
||||
/// This is a hybrid counter and instrusive mpsc channel (like `Queue`).
|
||||
/// This is a hybrid counter and intrusive mpsc channel (like `Queue`).
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Blocking {
|
||||
/// Queue head.
|
||||
|
||||
@@ -732,7 +732,7 @@ impl Worker {
|
||||
}
|
||||
}
|
||||
Shutdown | Running => {
|
||||
// To get here, the block above transitioned the tate to
|
||||
// To get here, the block above transitioned the state to
|
||||
// `Sleeping`. No other thread can concurrently
|
||||
// transition to `Shutdown` or `Running`.
|
||||
unreachable!();
|
||||
@@ -805,7 +805,7 @@ impl Worker {
|
||||
}
|
||||
}
|
||||
Shutdown | Running => {
|
||||
// To get here, the block above transitioned the tate to
|
||||
// To get here, the block above transitioned the state to
|
||||
// `Sleeping`. No other thread can concurrently
|
||||
// transition to `Shutdown` or `Running`.
|
||||
unreachable!();
|
||||
|
||||
@@ -46,7 +46,7 @@ pub(crate) const EMPTY: usize = MAX_WORKERS;
|
||||
/// Used to mark the stack as terminated
|
||||
pub(crate) const TERMINATED: usize = EMPTY + 1;
|
||||
|
||||
/// How many bits the treiber ABA guard is offset by
|
||||
/// How many bits the Treiber ABA guard is offset by
|
||||
const ABA_GUARD_SHIFT: usize = 16;
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
@@ -215,7 +215,7 @@ impl State {
|
||||
|
||||
#[inline]
|
||||
fn set_head(&mut self, val: usize) {
|
||||
// The ABA guard protects against the ABA problem w/ treiber stacks
|
||||
// The ABA guard protects against the ABA problem w/ Treiber stacks
|
||||
let aba_guard = ((self.0 >> ABA_GUARD_SHIFT) + 1) & ABA_GUARD_MASK;
|
||||
|
||||
self.0 = (aba_guard << ABA_GUARD_SHIFT) | val;
|
||||
|
||||
Reference in New Issue
Block a user