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/mod.rs:5 | /// will be executed on the thread pool.
pub(crate) fn block_on<F>(&self, future: F) -> F::Output
where
F: Future,
{
crate::runtime::global::with_thread_pool(self.spawner(), || {
let mut enter = crate::runtime::enter();
crate::runtime::blocking::with_pool(self.spawner... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/mod.rs | MIT | 4dbe6af0a1a1c8e579b92ec8ffc1d419244e0944 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4dbe6af0a1a1c8e579b92ec8ffc1d419244e0944/tokio/src/runtime/thread_pool/mod.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/mod.rs:6 | pub(crate) fn new(inner: P) -> Self {
BoxedPark { inner }
}
}
impl<P> Park for BoxedPark<P>
where
P: Park,
{
type Unpark = Box<dyn crate::runtime::park::Unpark>;
type Error = P::Error;
fn unpark(&self) -> Self::Unpark {
Box::new(self.inner.unpark())
}
fn park(&mut self) ->... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/mod.rs | MIT | 4dbe6af0a1a1c8e579b92ec8ffc1d419244e0944 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4dbe6af0a1a1c8e579b92ec8ffc1d419244e0944/tokio/src/runtime/thread_pool/mod.rs | 201 | 224 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/owned.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::runtime::thread_pool::{queue, Shared};
use crate::task::{self, Task};
use crate::util::FastRand;
use std::cell::Cell;
/// Per-worker data accessible only by the thread driving the worker.
#[derive(Debug)]
pub(super) struct Owned {
/// Worker generation. This ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/owned.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/runtime/thread_pool/owned.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/owned.rs:2 | /// List of tasks owned by the worker
pub(super) owned_tasks: task::OwnedList<Shared>,
}
impl Owned {
pub(super) fn new(work_queue: queue::Worker<Shared>, rand: FastRand) -> Owned {
Owned {
generation: AtomicUsize::new(0),
tick: Cell::new(1),
is_running: Cell::new(tr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/owned.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/runtime/thread_pool/owned.rs | 41 | 83 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/owned.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::runtime::thread_pool::{queue, Shared};
use crate::task::{self, Task};
use crate::util::FastRand;
use std::cell::Cell;
/// Per-worker data accessible only by the thread driving the worker.
#[derive(Debug)]
pub(super) struct Owned<P: 'static> {
/// Worker gener... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/owned.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/owned.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/owned.rs:2 | /// List of tasks owned by the worker
pub(super) owned_tasks: task::OwnedList<Shared<P>>,
}
impl<P> Owned<P>
where
P: 'static,
{
pub(super) fn new(work_queue: queue::Worker<Shared<P>>, rand: FastRand) -> Owned<P> {
Owned {
generation: AtomicUsize::new(0),
tick: Cell::new(1),... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/owned.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/owned.rs | 41 | 86 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/pool.rs:1 | use crate::runtime::blocking::PoolWaiter;
use crate::runtime::task::JoinHandle;
use crate::runtime::thread_pool::{shutdown, Spawner};
use std::fmt;
use std::future::Future;
/// Work-stealing based thread pool for executing futures.
pub(crate) struct ThreadPool {
spawner: Spawner,
/// Shutdown waiter
shut... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/pool.rs | MIT | 1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/pool.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/pool.rs:2 | pub(crate) fn spawn<F>(&self, future: F) -> JoinHandle<F::Output>
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
self.spawner.spawn(future)
}
/// Block the current thread waiting for the future to complete.
///
/// The future will execute on the current t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/pool.rs | MIT | 1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/pool.rs | 41 | 84 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:1 | //! Run-queue structures to support a work-stealing scheduler
use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::{AtomicU16, AtomicU32};
use crate::loom::sync::Arc;
use crate::runtime::task::{self, Inject};
use crate::runtime::MetricsBatch;
use std::mem::MaybeUninit;
use std::ptr;
use std::sync::atomic... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:2 | unsafe impl<T> Send for Inner<T> {}
unsafe impl<T> Sync for Inner<T> {}
#[cfg(not(loom))]
const LOCAL_QUEUE_CAPACITY: usize = 256;
// Shrink the size of the local queue when using loom. This shouldn't impact
// logic, but allows loom to test more edge cases in a reasonable a mount of
// time.
#[cfg(loom)]
const LOCAL... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:3 | let local = Local {
inner: inner.clone(),
};
let remote = Steal(inner);
(remote, local)
}
impl<T> Local<T> {
/// Returns true if the queue has entries that can be stolen.
pub(crate) fn is_stealable(&self) -> bool {
!self.inner.is_empty()
}
/// Returns false if there are a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:4 | } else if steal != real {
// Concurrently stealing, this will free up capacity, so only
// push the task onto the inject queue
inject.push(task);
return;
} else {
// Push the current task and half of the queue into the
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:5 | /// Once `push_overflow` is done, a notification is sent out, so if other
/// workers "missed" some of the tasks during a steal, they will get
/// another opportunity.
#[inline(never)]
fn push_overflow(
&mut self,
task: task::Notified<T>,
head: u16,
tail: u16,
inj... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:6 | .head
.compare_exchange(
prev,
pack(
head.wrapping_add(NUM_TASKS_TAKEN),
head.wrapping_add(NUM_TASKS_TAKEN),
),
Release,
Relaxed,
)
.is_err()
{
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:7 | Some(task)
}
}
}
// safety: The CAS above ensures that no consumer will look at these
// values again, and we are the only producer.
let batch_iter = BatchTaskIter {
buffer: &*self.inner.buffer,
head: head as u32,
i: 0,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:8 | pack(next_real, next_real)
} else {
assert_ne!(steal, next_real);
pack(steal, next_real)
};
// Attempt to claim a task.
let res = self
.inner
.head
.compare_exchange(head, next, AcqRel, Acqui... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:9 | let (steal, _) = unpack(dst.inner.head.load(Acquire));
if dst_tail.wrapping_sub(steal) > LOCAL_QUEUE_CAPACITY as u16 / 2 {
// we *could* try to steal less here, but for simplicity, we're just
// going to abort.
return None;
}
// Steal the tasks into `dst`'s ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:10 | // Steal tasks from `self`, placing them into `dst`. Returns the number of
// tasks that were stolen.
fn steal_into2(&self, dst: &mut Local<T>, dst_tail: u16) -> u16 {
let mut prev_packed = self.0.head.load(Acquire);
let mut next_packed;
let n = loop {
let (src_head_steal, s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:11 | Err(actual) => prev_packed = actual,
}
};
assert!(n <= LOCAL_QUEUE_CAPACITY as u16 / 2, "actual = {}", n);
let (first, _) = unpack(next_packed);
// Take all the tasks
for i in 0..n {
// Compute the positions
let src_pos = first.wrapping_add(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:12 | .0
.head
.compare_exchange(prev_packed, next_packed, AcqRel, Acquire);
match res {
Ok(_) => return n,
Err(actual) => {
let (actual_steal, actual_real) = unpack(actual);
assert_ne!(actual_steal, actual_r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:13 | impl<T> Inner<T> {
fn len(&self) -> u16 {
let (_, head) = unpack(self.head.load(Acquire));
let tail = self.tail.load(Acquire);
tail.wrapping_sub(head)
}
fn is_empty(&self) -> bool {
self.len() == 0
}
}
/// Split the head value into the real head and the index a stealer... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | 53cf021b813c61cdeace26e863c89f65f6e92abd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/53cf021b813c61cdeace26e863c89f65f6e92abd/tokio/src/runtime/thread_pool/queue.rs | 481 | 511 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:1 | //! Run-queue structures to support a work-stealing scheduler
use crate::loom::cell::{CausalCell, CausalCheck};
use crate::loom::sync::atomic::{self, AtomicU32, AtomicUsize};
use crate::loom::sync::{Arc, Mutex};
use crate::runtime::task;
use std::marker::PhantomData;
use std::mem::MaybeUninit;
use std::ptr::{self, No... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:2 | /// Only updated by producer thread but read by many threads.
tail: AtomicU32,
/// Elements
buffer: Box<[CausalCell<MaybeUninit<task::Notified<T>>>]>,
}
struct Pointers {
/// True if the queue is closed
is_closed: bool,
/// Linked-list head
head: Option<NonNull<task::Header>>,
/// Li... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:3 | for _ in 0..LOCAL_QUEUE_CAPACITY {
buffer.push(CausalCell::new(MaybeUninit::uninit()));
}
let inner = Arc::new(Inner {
head: AtomicU32::new(0),
tail: AtomicU32::new(0),
buffer: buffer.into(),
});
let local = Local {
inner: inner.clone(),
next: None,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:4 | self.next = Some(task);
ret
}
/// Pushes a task to the back of the local queue, skipping the LIFO slot.
pub(super) fn push_back(&mut self, mut task: task::Notified<T>, inject: &Inject<T>) {
loop {
let head = self.inner.head.load(Acquire);
// safety: this is the **o... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:5 | // Lost the race, try again
Err(v) => task = v,
}
atomic::spin_loop_hint();
}
}
/// Moves a batch of tasks into the inject queue.
///
/// This will temporarily make some of the tasks unavailable to stealers.
/// Once `push_overflow` is done, a notifi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:6 | // this function and try the full `push` routine again. The queue
// may not be full anymore.
return Err(task);
}
// link the tasks
for i in 0..n {
let j = i + 1;
let i_idx = (i + head) as usize & MASK;
let j_idx = (j + head) as usize... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:7 | Ok(())
}
/// Pops a task from the local queue.
pub(super) fn pop(&mut self) -> Option<task::Notified<T>> {
// If a task is available in the FIFO slot, return that.
if let Some(task) = self.next.take() {
return Some(task);
}
loop {
let head = self.inn... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:8 | // safety: we claimed the task and the data we read is
// initialized memory.
return Some(unsafe { task.assume_init() });
}
atomic::spin_loop_hint();
}
}
}
impl<T> Steal<T> {
pub(super) fn is_empty(&self) -> bool {
self.0.is_empty()
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:9 | if n == 0 {
// The `dst` queue is empty, but a single task was stolen
return Some(ret);
}
// Synchronize with stealers
let dst_head = dst.inner.head.load(Acquire);
assert!(dst_tail.wrapping_sub(dst_head) + n <= LOCAL_QUEUE_CAPACITY as u32);
// Make the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:10 | // Compute the positions
let src_pos = src_head.wrapping_add(i);
let dst_pos = dst_tail.wrapping_add(i);
// Map to slots
let src_idx = src_pos as usize & MASK;
let dst_idx = dst_pos as usize & MASK;
// Read the task
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:11 | }
}
impl<T> Drop for Local<T> {
fn drop(&mut self) {
if !std::thread::panicking() {
assert!(self.pop().is_none(), "queue not empty");
}
}
}
impl<T> Inner<T> {
fn is_empty(&self) -> bool {
let head = self.head.load(Acquire);
let tail = self.tail.load(Acquire);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:12 | let mut p = self.pointers.lock().unwrap();
if p.is_closed {
return false;
}
p.is_closed = true;
true
}
pub(super) fn is_closed(&self) -> bool {
self.pointers.lock().unwrap().is_closed
}
fn len(&self) -> usize {
self.len.load(Acquire)
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:13 | } else {
p.head = Some(task);
}
p.tail = Some(task);
self.len.store(len + 1, Release);
}
pub(super) fn push_batch(
&self,
batch_head: task::Notified<T>,
batch_tail: task::Notified<T>,
num: usize,
) {
let batch_head = batch_head.i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue.rs:14 | // Fast path, if len == 0, then there are no values
if self.is_empty() {
return None;
}
let mut p = self.pointers.lock().unwrap();
// It is possible to hit null here if another thread poped the last
// task between us checking `len` and acquiring the lock.
l... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/queue.rs | 521 | 568 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Mutex;
use crate::task::{Header, Task};
use std::marker::PhantomData;
use std::ptr::{self, NonNull};
use std::sync::atomic::Ordering::{Acquire, Release};
use std::usize;
pub(super) struct Queue<T: 'static> {
/// Pointers to the head and tail of th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/global.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:2 | }
pub(super) fn is_empty(&self) -> bool {
self.len() == 0
}
pub(super) fn is_closed(&self) -> bool {
self.len.load(Acquire) & CLOSED == CLOSED
}
/// Close the worker queue
pub(super) fn close(&self) -> bool {
// Acquire the lock
let p = self.pointers.lock().unw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/global.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:3 | /// Pushes a value into the queue and call the closure **while still holding
/// the push lock**
pub(super) fn push<F>(&self, task: Task<T>, f: F)
where
F: FnOnce(Result<(), Task<T>>),
{
unsafe {
// Acquire queue lock
let mut p = self.pointers.lock().unwrap();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/global.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:4 | std::process::abort();
}
self.len.store(len + 2, Release);
f(Ok(()));
drop(p);
}
}
pub(super) fn push_batch(&self, batch_head: Task<T>, batch_tail: Task<T>, num: usize) {
unsafe {
let batch_head = batch_head.into_raw().as_ptr();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/global.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:5 | self.len.store(len + (num << 1), Release);
drop(p);
}
}
pub(super) fn pop(&self) -> Option<Task<T>> {
// Fast path, if len == 0, then there are no values
if self.is_empty() {
return None;
}
unsafe {
let mut p = self.pointers.lock().u... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/global.rs | 161 | 209 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:2 | }
pub(super) fn is_empty(&self) -> bool {
self.len() == 0
}
pub(super) fn is_closed(&self) -> bool {
self.len.load(Acquire) & CLOSED == CLOSED
}
/// Close the worker queue
pub(super) fn close(&self) -> bool {
// Acquire the lock
let p = self.pointers.lock().unw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | 275769b5b90e9cf33c8d37f1ba176cacb508399e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/275769b5b90e9cf33c8d37f1ba176cacb508399e/tokio/src/runtime/thread_pool/queue/global.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:3 | /// Push a value into the queue and call the closure **while still holding
/// the push lock**
pub(super) fn push<F>(&self, task: Task<T>, f: F)
where
F: FnOnce(Result<(), Task<T>>),
{
unsafe {
// Acquire queue lock
let mut p = self.pointers.lock().unwrap();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | 275769b5b90e9cf33c8d37f1ba176cacb508399e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/275769b5b90e9cf33c8d37f1ba176cacb508399e/tokio/src/runtime/thread_pool/queue/global.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:2 | }
pub(super) fn is_empty(&self) -> bool {
self.len() == 0
}
pub(super) fn is_closed(&self) -> bool {
self.len.load(Acquire) & CLOSED == CLOSED
}
/// Close the worker queue
pub(super) fn close(&self) -> bool {
// Acquire the lock
let p = self.pointers.lock().unw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | 7c8b8877d440629ab9a27a2c9dcef859835d3536 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c8b8877d440629ab9a27a2c9dcef859835d3536/tokio/src/runtime/thread_pool/queue/global.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:3 | /// Push a value into the queue and call the closure **while still holding
/// the push lock**
pub(super) fn push<F>(&self, task: Task<T>, f: F)
where
F: FnOnce(Result<(), Task<T>>),
{
unsafe {
// Acquire queue lock
let mut p = self.pointers.lock().unwrap();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | 7c8b8877d440629ab9a27a2c9dcef859835d3536 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c8b8877d440629ab9a27a2c9dcef859835d3536/tokio/src/runtime/thread_pool/queue/global.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:4 | }
self.len.store(len + 2, Release);
f(Ok(()));
drop(p);
}
}
pub(super) fn push_batch(&self, batch_head: Task<T>, batch_tail: Task<T>, num: usize) {
unsafe {
let batch_head = batch_head.into_raw().as_ptr();
let batch_tail = batch_tai... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | 7c8b8877d440629ab9a27a2c9dcef859835d3536 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c8b8877d440629ab9a27a2c9dcef859835d3536/tokio/src/runtime/thread_pool/queue/global.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:5 | drop(p);
}
}
pub(super) fn pop(&self) -> Option<Task<T>> {
// Fast path, if len == 0, then there are no values
if self.is_empty() {
return None;
}
unsafe {
let mut p = self.pointers.lock().unwrap();
// It is possible to hit null here... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | 7c8b8877d440629ab9a27a2c9dcef859835d3536 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c8b8877d440629ab9a27a2c9dcef859835d3536/tokio/src/runtime/thread_pool/queue/global.rs | 161 | 208 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:1 | use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Mutex;
use crate::task::{Header, Task};
use std::marker::PhantomData;
use std::ptr::{self, NonNull};
use std::sync::atomic::Ordering::{Acquire, Release};
use std::usize;
pub(super) struct Queue<T: 'static> {
/// Pointers to the head and tail of th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/global.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:2 | }
pub(super) fn is_empty(&self) -> bool {
self.len() == 0
}
pub(super) fn is_closed(&self) -> bool {
self.len.load(Acquire) & CLOSED == CLOSED
}
/// Close the worker queue
pub(super) fn close(&self) -> bool {
// Acquire the lock
let _p = self.pointers.lock().un... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/global.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:3 | /// the push lock**
pub(super) fn push<F>(&self, task: Task<T>, f: F)
where
F: FnOnce(Result<(), Task<T>>),
{
unsafe {
// Acquire queue lock
let mut p = self.pointers.lock().unwrap();
// Check if the queue is closed. This must happen in the lock.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/global.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:4 | self.len.store(len + 2, Release);
f(Ok(()));
}
}
pub(super) fn push_batch(&self, batch_head: Task<T>, batch_tail: Task<T>, num: usize) {
unsafe {
let batch_head = batch_head.into_raw().as_ptr();
let batch_tail = batch_tail.into_raw();
debug_asser... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/global.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/global.rs:5 | if self.is_empty() {
return None;
}
unsafe {
let mut p = self.pointers.lock().unwrap();
// It is possible to hit null here if another thread poped the last
// task between us checking `len` and acquiring the lock.
let task = NonNull::new(p.he... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/global.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/global.rs | 161 | 199 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/inject.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::thread_pool::queue::Cluster;
use crate::task::Task;
pub(crate) struct Inject<T: 'static> {
cluster: Arc<Cluster<T>>,
}
impl<T: 'static> Inject<T> {
pub(super) fn new(cluster: Arc<Cluster<T>>) -> Inject<T> {
Inject { cluster }
}
/// Pushes a valu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/inject.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/inject.rs | 1 | 41 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/inject.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::thread_pool::queue::Cluster;
use crate::task::Task;
pub(crate) struct Inject<T: 'static> {
cluster: Arc<Cluster<T>>,
}
impl<T: 'static> Inject<T> {
pub(super) fn new(cluster: Arc<Cluster<T>>) -> Inject<T> {
Inject { cluster }
}
/// Push a value ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/inject.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/inject.rs | 1 | 41 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:1 | use crate::loom::cell::{CausalCell, CausalCheck};
use crate::loom::sync::atomic::{self, AtomicU32};
use crate::runtime::thread_pool::queue::global;
use crate::runtime::thread_pool::LOCAL_QUEUE_CAPACITY;
use crate::task::Task;
use std::fmt;
use std::mem::MaybeUninit;
use std::ptr;
use std::sync::atomic::Ordering::{Acqu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/local.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:2 | }
impl<T> Queue<T> {
/// Pushes a task onto the local queue.
///
/// This **must** be called by the producer thread.
pub(super) unsafe fn push(&self, mut task: Task<T>, global: &global::Queue<T>) {
loop {
let head = self.head.load(Acquire);
// safety: this is the **only... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/local.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:3 | /// Moves a batch of tasks into the global queue.
///
/// This will temporarily make some of the tasks unavailable to stealers.
/// Once `push_overflow` is done, a notification is sent out, so if other
/// workers "missed" some of the tasks during a steal, they will get
/// another opportunity.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/local.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:4 | let i_idx = (i + head) as usize & MASK;
let j_idx = (j + head) as usize & MASK;
// Get the next pointer
let next = if j == n {
// The last task in the local queue being moved
task.header() as *const _
} else {
self.buffer[j... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/local.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:5 | if head == tail {
// queue is empty
return None;
}
// Map the head position to a slot index.
let idx = head as usize & MASK;
let task = self.buffer[idx].with(|ptr| {
// Tentatively read the task at the head position. Note ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/local.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:6 | // tasks in `dst`.
let mut n = self.steal2(dst, dst_tail);
if n == 0 {
// No tasks were stolen
return None;
}
// We are returning a task here
n -= 1;
let ret_pos = dst_tail.wrapping_add(n);
let ret_idx = ret_pos as usize & MASK;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/local.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:7 | if n == 0 {
return 0;
}
if n > LOCAL_QUEUE_CAPACITY as u32 / 2 {
atomic::spin_loop_hint();
// inconsistent, try again
continue;
}
// Track CausalCell causality checks. The check is deferred until
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/local.rs | 241 | 298 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:8 | check.check();
return n;
}
atomic::spin_loop_hint();
}
}
}
impl<T> fmt::Debug for Queue<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("local::Queue")
.field("head", &self.head)
.field("tail", &... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/local.rs | 281 | 298 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:1 | use crate::loom::cell::{CausalCell, CausalCheck};
use crate::loom::sync::atomic::{self, AtomicU32};
use crate::runtime::thread_pool::queue::global;
use crate::runtime::thread_pool::LOCAL_QUEUE_CAPACITY;
use crate::task::Task;
use std::fmt;
use std::mem::MaybeUninit;
use std::ptr;
use std::sync::atomic::Ordering::{Acqu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/local.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:2 | }
impl<T> Queue<T> {
/// Push a task onto the local queue.
///
/// This **must** be called by the producer thread.
pub(super) unsafe fn push(&self, mut task: Task<T>, global: &global::Queue<T>) {
loop {
let head = self.head.load(Acquire);
// safety: this is the **only**... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/local.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:3 | /// Move a batch of tasks into the global queue.
///
/// This will temporarily make some of the tasks unavailable to stealers.
/// Once `push_overflow` is done, a notification is sent out, so if other
/// workers "missed" some of the tasks during a steal, they will get
/// another opportunity.
#... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/local.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:4 | let i_idx = (i + head) as usize & MASK;
let j_idx = (j + head) as usize & MASK;
// Get the next pointer
let next = if j == n {
// The last task in the local queue being moved
task.header() as *const _
} else {
self.buffer[j... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/local.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/local.rs:5 | if head == tail {
// queue is empty
return None;
}
// Map the head position to a slot index.
let idx = head as usize & MASK;
let task = self.buffer[idx].with(|ptr| {
// Tentatively read the task at the head position. Note ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/local.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/local.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/worker.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::thread_pool::queue::{local, Cluster, Inject};
use crate::task::Task;
use std::cell::Cell;
use std::fmt;
pub(crate) struct Worker<T: 'static> {
cluster: Arc<Cluster<T>>,
index: u16,
/// Task to pop next
next: Cell<Option<Task<T>>>,
}
impl<T: 'static> Wor... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/worker.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/worker.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/worker.rs:2 | let prev = self.next.take();
let ret = prev.is_some();
if let Some(prev) = prev {
// safety: we guarantee that only one thread pushes to this local
// queue at a time.
unsafe {
self.local().push(prev, &self.cluster.global);
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/worker.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/worker.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/worker.rs:3 | continue;
}
// safety: we own the dst queue
let ret = unsafe { self.cluster.local[i].steal(self.local()) };
if ret.is_some() {
return ret;
}
}
None
}
/// An approximation of whether or not the queue is empty.
pub... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/worker.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/queue/worker.rs | 81 | 127 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/worker.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::thread_pool::queue::{local, Cluster, Inject};
use crate::task::Task;
use std::cell::Cell;
use std::fmt;
pub(crate) struct Worker<T: 'static> {
cluster: Arc<Cluster<T>>,
index: u16,
/// Task to pop next
next: Cell<Option<Task<T>>>,
}
impl<T: 'static> Wor... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/worker.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/worker.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/queue/worker.rs:2 | let prev = self.next.take();
let ret = prev.is_some();
if let Some(prev) = prev {
// safety: we guarantee that only one thread pushes to this local
// queue at a time.
unsafe {
self.local().push(prev, &self.cluster.global);
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/queue/worker.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/queue/worker.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/shared.rs:1 | use crate::park::Unpark;
use crate::runtime::thread_pool::slice;
use crate::runtime::Unparker;
use crate::task::{self, Schedule, ScheduleSendOnly, Task};
use std::ptr;
/// Per-worker data accessible from any thread.
///
/// Accessed by:
///
/// - other workers
/// - tasks
///
pub(crate) struct Shared {
/// Thread... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/shared.rs | MIT | 38e602f4d812c196d5dc0bc245e79ccad4e77cfd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/38e602f4d812c196d5dc0bc245e79ccad4e77cfd/tokio/src/runtime/thread_pool/shared.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/shared.rs:2 | pub(crate) fn schedule(&self, task: Task<Self>) {
self.slices().schedule(task);
}
pub(super) fn unpark(&self) {
self.unpark.unpark();
}
fn slices(&self) -> &slice::Set {
unsafe { &*self.slices }
}
pub(super) fn set_slices_ptr(&mut self, slices: *const slice::Set) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/shared.rs | MIT | 38e602f4d812c196d5dc0bc245e79ccad4e77cfd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/38e602f4d812c196d5dc0bc245e79ccad4e77cfd/tokio/src/runtime/thread_pool/shared.rs | 41 | 94 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/shared.rs:3 | unsafe {
let index = self.slices().index_of(self);
let owned = &mut *self.slices().owned()[index].get();
owned.release_task(task);
}
}
fn schedule(&self, task: Task<Self>) {
Self::schedule(self, task);
}
}
impl ScheduleSendOnly for Shared {} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/shared.rs | MIT | 38e602f4d812c196d5dc0bc245e79ccad4e77cfd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/38e602f4d812c196d5dc0bc245e79ccad4e77cfd/tokio/src/runtime/thread_pool/shared.rs | 81 | 94 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/shared.rs:1 | use crate::park::Unpark;
use crate::runtime::Unparker;
use crate::runtime::thread_pool::slice;
use crate::task::{self, Schedule, Task};
use std::ptr;
/// Per-worker data accessible from any thread.
///
/// Accessed by:
///
/// - other workers
/// - tasks
///
pub(crate) struct Shared {
/// Thread unparker
unpa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/shared.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/runtime/thread_pool/shared.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/shared.rs:2 | pub(crate) fn schedule(&self, task: Task<Self>) {
self.slices().schedule(task);
}
pub(super) fn unpark(&self) {
self.unpark.unpark();
}
fn slices(&self) -> &slice::Set {
unsafe { &*self.slices }
}
pub(super) fn set_slices_ptr(&mut self, slices: *const slice::Set) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/shared.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/runtime/thread_pool/shared.rs | 41 | 92 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/shared.rs:3 | unsafe {
let index = self.slices().index_of(self);
let owned = &mut *self.slices().owned()[index].get();
owned.release_task(task);
}
}
fn schedule(&self, task: Task<Self>) {
Self::schedule(self, task);
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/shared.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/runtime/thread_pool/shared.rs | 81 | 92 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/shared.rs:1 | use crate::runtime::park::Unpark;
use crate::runtime::thread_pool::slice;
use crate::task::{self, Schedule, Task};
use std::ptr;
/// Per-worker data accessible from any thread.
///
/// Accessed by:
///
/// - other workers
/// - tasks
///
pub(crate) struct Shared<P>
where
P: 'static,
{
/// Thread unparker
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/shared.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/shared.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/shared.rs:2 | unpark,
pending_drop: task::TransferStack::new(),
slices: ptr::null(),
}
}
pub(crate) fn schedule(&self, task: Task<Self>) {
self.slices().schedule(task);
}
pub(super) fn unpark(&self) {
self.unpark.unpark();
}
fn slices(&self) -> &slice::Set<P>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/shared.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/shared.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/shared.rs:3 | // notified. Instead, the worker will clean up the tasks "eventually".
//
self.pending_drop.push(task);
}
fn release_local(&self, task: &Task<Self>) {
// Get access to the Owned component. This function can only be called
// when on the worker.
unsafe {
let i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/shared.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/shared.rs | 81 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/shutdown.rs:1 | //! A shutdown channel.
//!
//! Each worker holds the `Sender` half. When all the `Sender` halves are
//! dropped, the `Receiver` receives a notification.
use crate::loom::sync::Arc;
use crate::sync::oneshot;
#[derive(Debug, Clone)]
pub(super) struct Sender {
tx: Arc<oneshot::Sender<()>>,
}
#[derive(Debug)]
pub(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/shutdown.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/shutdown.rs | 1 | 44 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:1 | //! The scheduler is divided into multiple slices. Each slice is fairly
//! isolated, having its own queue. A worker is dedicated to processing a single
//! slice.
use crate::loom::rand::seed;
use crate::park::Park;
use crate::runtime::thread_pool::{current, queue, Idle, Owned, Shared};
use crate::runtime::Parker;
use... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/slice.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:2 | let mut owned = Vec::with_capacity(queues.len());
for (i, queue) in queues.into_iter().enumerate() {
let rand = FastRand::new(seed());
shared.push(Shared::new(parkers[i].unpark()));
owned.push(UnsafeCell::new(CachePadded::new(Owned::new(queue, rand))));
}
S... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/slice.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:3 | self.notify_work();
}
});
}
pub(super) fn notify_work(&self) {
if let Some(index) = self.idle.worker_to_notify() {
self.shared[index].unpark();
}
}
pub(super) fn notify_all(&self) {
for shared in &self.shared[..] {
shared.unpark();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/slice.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:4 | /// indicates the pool was already closed.
pub(crate) fn close(&self) -> bool {
if self.inject.close() {
self.notify_all();
true
} else {
false
}
}
pub(crate) fn is_closed(&self) -> bool {
self.inject.is_closed()
}
pub(crate) fn l... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/slice.rs | 121 | 172 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:5 | /// This is done by locking w/o doing anything.
pub(super) fn wait_for_unlocked(&self) {
self.inject.wait_for_unlocked();
}
}
impl Drop for Set {
fn drop(&mut self) {
// Before proceeding, wait for all concurrent wakers to exit
self.wait_for_unlocked();
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/slice.rs | 161 | 172 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:1 | //! The scheduler is divided into multiple slices. Each slice is fairly
//! isolated, having its own queue. A worker is dedicated to processing a single
//! slice.
use crate::loom::rand::seed;
use crate::park::Park;
use crate::runtime::thread_pool::{current, queue, Idle, Owned, Shared};
use crate::runtime::Parker;
use... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | 8656b7b8eb6f3635ec40694eb71f14fb84211e05 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8656b7b8eb6f3635ec40694eb71f14fb84211e05/tokio/src/runtime/thread_pool/slice.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:3 | self.notify_work();
}
});
}
pub(super) fn notify_work(&self) {
if let Some(index) = self.idle.worker_to_notify() {
self.shared[index].unpark();
}
}
pub(super) fn notify_all(&self) {
for shared in &self.shared[..] {
shared.unpark();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | 8656b7b8eb6f3635ec40694eb71f14fb84211e05 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8656b7b8eb6f3635ec40694eb71f14fb84211e05/tokio/src/runtime/thread_pool/slice.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:4 | /// indicates the pool was already closed.
pub(crate) fn close(&self) -> bool {
if self.inject.close() {
self.notify_all();
true
} else {
false
}
}
pub(crate) fn is_closed(&self) -> bool {
self.inject.is_closed()
}
pub(crate) fn l... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | 8656b7b8eb6f3635ec40694eb71f14fb84211e05 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8656b7b8eb6f3635ec40694eb71f14fb84211e05/tokio/src/runtime/thread_pool/slice.rs | 121 | 172 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:1 | //! The scheduler is divided into multiple slices. Each slice is fairly
//! isolated, having its own queue. A worker is dedicated to processing a single
//! slice.
use crate::loom::rand::seed;
use crate::park::Park;
use crate::runtime::Parker;
use crate::runtime::thread_pool::{current, queue, Idle, Owned, Shared};
use... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/runtime/thread_pool/slice.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:1 | //! The scheduler is divided into multiple slices. Each slice is fairly
//! isolated, having its own queue. A worker is dedicated to processing a single
//! slice.
use crate::loom::rand::seed;
use crate::runtime::park::Unpark;
use crate::runtime::thread_pool::{current, queue, Idle, Owned, Shared};
use crate::task::{se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | 19f1fc36bd567377bde4a2c6818c6b606d89d488 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/19f1fc36bd567377bde4a2c6818c6b606d89d488/tokio/src/runtime/thread_pool/slice.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:2 | F: FnMut(usize) -> P,
{
assert!(num_workers > 0);
let queues = queue::build(num_workers);
let inject = queues[0].injector();
let mut shared = Vec::with_capacity(queues.len());
let mut owned = Vec::with_capacity(queues.len());
for (i, queue) in queues.into_iter().en... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | 19f1fc36bd567377bde4a2c6818c6b606d89d488 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/19f1fc36bd567377bde4a2c6818c6b606d89d488/tokio/src/runtime/thread_pool/slice.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:3 | self.notify_work();
}
});
}
pub(super) fn notify_work(&self) {
if let Some(index) = self.idle.worker_to_notify() {
self.shared[index].unpark();
}
}
pub(super) fn notify_all(&self) {
for shared in &self.shared[..] {
shared.unpark();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | 19f1fc36bd567377bde4a2c6818c6b606d89d488 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/19f1fc36bd567377bde4a2c6818c6b606d89d488/tokio/src/runtime/thread_pool/slice.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:4 | /// indicates the pool was already closed.
pub(crate) fn close(&self) -> bool {
if self.inject.close() {
self.notify_all();
true
} else {
false
}
}
pub(crate) fn is_closed(&self) -> bool {
self.inject.is_closed()
}
pub(crate) fn l... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | 19f1fc36bd567377bde4a2c6818c6b606d89d488 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/19f1fc36bd567377bde4a2c6818c6b606d89d488/tokio/src/runtime/thread_pool/slice.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/slice.rs:5 | /// Wait for all locks on the injection queue to drop.
///
/// This is done by locking w/o doing anything.
pub(super) fn wait_for_unlocked(&self) {
self.inject.wait_for_unlocked();
}
}
impl<P: 'static> Drop for Set<P> {
fn drop(&mut self) {
// Before proceeding, wait for all concurr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/slice.rs | MIT | 19f1fc36bd567377bde4a2c6818c6b606d89d488 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/19f1fc36bd567377bde4a2c6818c6b606d89d488/tokio/src/runtime/thread_pool/slice.rs | 161 | 186 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/spawner.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::thread_pool::slice;
use crate::task::JoinHandle;
use std::fmt;
use std::future::Future;
/// Submit futures to the associated thread pool for execution.
///
/// A `Spawner` instance is a handle to a single thread pool, allowing the owner
/// of the handle to spawn future... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/spawner.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/runtime/thread_pool/spawner.rs | 1 | 49 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/spawner.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::thread_pool::slice;
use crate::task::JoinHandle;
use std::fmt;
use std::future::Future;
/// Submit futures to the associated thread pool for execution.
///
/// A `Spawner` instance is a handle to a single thread pool, allowing the owner
/// of the handle to spawn future... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/spawner.rs | MIT | 67bf9c36f347031ca05872d102a7f9abc8b465f0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/67bf9c36f347031ca05872d102a7f9abc8b465f0/tokio/src/runtime/thread_pool/spawner.rs | 1 | 49 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/spawner.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::thread_pool::slice;
use crate::task::JoinHandle;
use std::fmt;
use std::future::Future;
/// Submit futures to the associated thread pool for execution.
///
/// A `Spawner` instance is a handle to a single thread pool, allowing the owner
/// of the handle to spawn future... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/spawner.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/runtime/thread_pool/spawner.rs | 1 | 57 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/spawner.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::park::Unpark;
use crate::runtime::thread_pool::slice;
use crate::task::JoinHandle;
use std::fmt;
use std::future::Future;
/// Submit futures to the associated thread pool for execution.
///
/// A `Spawner` instance is a handle to a single thread pool, allowing the owner... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/spawner.rs | MIT | 4d19a999371190e25f6138916d93e6c75093e4a6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4d19a999371190e25f6138916d93e6c75093e4a6/tokio/src/runtime/thread_pool/spawner.rs | 1 | 58 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/spawner.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::park::Unpark;
use crate::runtime::thread_pool::slice;
use crate::task::JoinHandle;
use std::fmt;
use std::future::Future;
/// Submit futures to the associated thread pool for execution.
///
/// A `Spawner` instance is a handle to a single thread pool, allowing the owner... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/spawner.rs | MIT | 19f1fc36bd567377bde4a2c6818c6b606d89d488 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/19f1fc36bd567377bde4a2c6818c6b606d89d488/tokio/src/runtime/thread_pool/spawner.rs | 1 | 50 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.