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/scheduler/multi_thread/park.rs:1
//! Parks the runtime. //! //! A combination of the various resource driver park handles. use crate::loom::sync::atomic::AtomicUsize; use crate::loom::sync::{Arc, Condvar, Mutex}; use crate::runtime::driver::{self, Driver}; use crate::util::TryLock; use std::sync::atomic::Ordering::SeqCst; use std::time::Duration; p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
131e7b4e49c8849298ba54b4e0c99f4b81d869e3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/scheduler/multi_thread/park.rs
1
60
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:2
struct Shared { /// Shared driver. Only one thread at a time can use this driver: TryLock<Driver>, } impl Parker { pub(crate) fn new(driver: Driver) -> Parker { Parker { inner: Arc::new(Inner { state: AtomicUsize::new(EMPTY), mutex: Mutex::new(()), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
131e7b4e49c8849298ba54b4e0c99f4b81d869e3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/scheduler/multi_thread/park.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:3
} } impl Clone for Parker { fn clone(&self) -> Parker { Parker { inner: Arc::new(Inner { state: AtomicUsize::new(EMPTY), mutex: Mutex::new(()), condvar: Condvar::new(), shared: self.inner.shared.clone(), }), } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
131e7b4e49c8849298ba54b4e0c99f4b81d869e3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/scheduler/multi_thread/park.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:4
} fn park_condvar(&self) { // Otherwise we need to coordinate going to sleep let mut m = self.mutex.lock(); match self .state .compare_exchange(EMPTY, PARKED_CONDVAR, SeqCst, SeqCst) { Ok(_) => {} Err(NOTIFIED) => { //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
131e7b4e49c8849298ba54b4e0c99f4b81d869e3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/scheduler/multi_thread/park.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:5
} fn park_driver(&self, driver: &mut Driver, handle: &driver::Handle) { match self .state .compare_exchange(EMPTY, PARKED_DRIVER, SeqCst, SeqCst) { Ok(_) => {} Err(NOTIFIED) => { // We must read here, even though we know it will be `NO...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
131e7b4e49c8849298ba54b4e0c99f4b81d869e3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/scheduler/multi_thread/park.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:6
NOTIFIED => {} // already unparked PARKED_CONDVAR => self.unpark_condvar(), PARKED_DRIVER => driver.unpark(), actual => panic!("inconsistent state in unpark; actual = {}", actual), } } fn unpark_condvar(&self) { // There is a period between when the parked th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
131e7b4e49c8849298ba54b4e0c99f4b81d869e3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/scheduler/multi_thread/park.rs
201
232
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:1
//! Parks the runtime. //! //! A combination of the various resource driver park handles. use crate::loom::sync::atomic::AtomicUsize; use crate::loom::sync::{Arc, Condvar, Mutex}; use crate::runtime::driver::{self, Driver}; use crate::util::TryLock; use std::sync::atomic::Ordering::SeqCst; use std::time::Duration; p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/scheduler/multi_thread/park.rs
1
60
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:1
//! Parks the runtime. //! //! A combination of the various resource driver park handles. use crate::loom::sync::atomic::AtomicUsize; use crate::loom::sync::{Arc, Condvar, Mutex}; use crate::loom::thread; use crate::runtime::driver::{self, Driver}; use crate::util::TryLock; use std::sync::atomic::Ordering::SeqCst; us...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/scheduler/multi_thread/park.rs
1
60
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:2
/// Shared across multiple Parker handles struct Shared { /// Shared driver. Only one thread at a time can use this driver: TryLock<Driver>, } impl Parker { pub(crate) fn new(driver: Driver) -> Parker { Parker { inner: Arc::new(Inner { state: AtomicUsize::new(EMPTY), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/scheduler/multi_thread/park.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:3
self.inner.shutdown(handle); } } impl Clone for Parker { fn clone(&self) -> Parker { Parker { inner: Arc::new(Inner { state: AtomicUsize::new(EMPTY), mutex: Mutex::new(()), condvar: Condvar::new(), shared: self.inner.shared.clo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/scheduler/multi_thread/park.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:4
if let Some(mut driver) = self.shared.driver.try_lock() { self.park_driver(&mut driver, handle); } else { self.park_condvar(); } } fn park_condvar(&self) { // Otherwise we need to coordinate going to sleep let mut m = self.mutex.lock(); match sel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/scheduler/multi_thread/park.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:5
return; } // spurious wakeup, go back to sleep } } fn park_driver(&self, driver: &mut Driver, handle: &driver::Handle) { match self .state .compare_exchange(EMPTY, PARKED_DRIVER, SeqCst, SeqCst) { Ok(_) => {} Err(N...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/scheduler/multi_thread/park.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:6
// synchronize with. To do that we must write `NOTIFIED` even if `state` // is already `NOTIFIED`. That is why this must be a swap rather than a // compare-and-swap that returns if it reads `NOTIFIED` on failure. match self.state.swap(NOTIFIED, SeqCst) { EMPTY => {} // no one was ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
a03e0420249d1740668f608a5a16f1fa614be2c7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a03e0420249d1740668f608a5a16f1fa614be2c7/tokio/src/runtime/scheduler/multi_thread/park.rs
201
237
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:2
/// Shared across multiple Parker handles struct Shared { /// Shared driver. Only one thread at a time can use this driver: TryLock<Driver>, } impl Parker { pub(crate) fn new(driver: Driver) -> Parker { Parker { inner: Arc::new(Inner { state: AtomicUsize::new(EMPTY), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/scheduler/multi_thread/park.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:3
self.inner.shutdown(); } } impl Clone for Parker { fn clone(&self) -> Parker { Parker { inner: Arc::new(Inner { state: AtomicUsize::new(EMPTY), mutex: Mutex::new(()), condvar: Condvar::new(), shared: self.inner.shared.clone(), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/scheduler/multi_thread/park.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:4
if let Some(mut driver) = self.shared.driver.try_lock() { self.park_driver(&mut driver); } else { self.park_condvar(); } } fn park_condvar(&self) { // Otherwise we need to coordinate going to sleep let mut m = self.mutex.lock(); match self ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/scheduler/multi_thread/park.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:5
return; } // spurious wakeup, go back to sleep } } fn park_driver(&self, driver: &mut Driver) { match self .state .compare_exchange(EMPTY, PARKED_DRIVER, SeqCst, SeqCst) { Ok(_) => {} Err(NOTIFIED) => { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/scheduler/multi_thread/park.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:6
// synchronize with. To do that we must write `NOTIFIED` even if `state` // is already `NOTIFIED`. That is why this must be a swap rather than a // compare-and-swap that returns if it reads `NOTIFIED` on failure. match self.state.swap(NOTIFIED, SeqCst) { EMPTY => {} // no one was ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
0b92f80a6506c6a89eb998e5f61a33415353bba1
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0b92f80a6506c6a89eb998e5f61a33415353bba1/tokio/src/runtime/scheduler/multi_thread/park.rs
201
237
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:2
/// Shared across multiple Parker handles struct Shared { /// Shared driver. Only one thread at a time can use this driver: TryLock<Driver>, } impl Parker { pub(crate) fn new(driver: Driver) -> Parker { Parker { inner: Arc::new(Inner { state: AtomicUsize::new(EMPTY), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
cba5c1009e3a1e6a0e87afcd380f2427485785ec
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cba5c1009e3a1e6a0e87afcd380f2427485785ec/tokio/src/runtime/scheduler/multi_thread/park.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:3
self.inner.shutdown(); } } impl Clone for Parker { fn clone(&self) -> Parker { Parker { inner: Arc::new(Inner { state: AtomicUsize::new(EMPTY), mutex: Mutex::new(()), condvar: Condvar::new(), shared: self.inner.shared.clone(), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
cba5c1009e3a1e6a0e87afcd380f2427485785ec
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cba5c1009e3a1e6a0e87afcd380f2427485785ec/tokio/src/runtime/scheduler/multi_thread/park.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:5
return; } // spurious wakeup, go back to sleep } } fn park_driver(&self, driver: &mut Driver) { match self .state .compare_exchange(EMPTY, PARKED_DRIVER, SeqCst, SeqCst) { Ok(_) => {} Err(NOTIFIED) => { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
cba5c1009e3a1e6a0e87afcd380f2427485785ec
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cba5c1009e3a1e6a0e87afcd380f2427485785ec/tokio/src/runtime/scheduler/multi_thread/park.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:1
//! Parks the runtime. //! //! A combination of the various resource driver park handles. use crate::loom::sync::atomic::AtomicUsize; use crate::loom::sync::{Arc, Condvar, Mutex}; use crate::loom::thread; use crate::runtime::driver::{Driver, Unpark}; use crate::util::TryLock; use std::sync::atomic::Ordering::SeqCst; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
99aa8d12b7ad2ef011a7a9f652f7455b3f175821
github
async-runtime
https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/multi_thread/park.rs
1
60
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:2
/// Shared across multiple Parker handles struct Shared { /// Shared driver. Only one thread at a time can use this driver: TryLock<Driver>, /// Unpark handle handle: Unpark, } impl Parker { pub(crate) fn new(driver: Driver) -> Parker { let handle = driver.unpark(); Parker { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
99aa8d12b7ad2ef011a7a9f652f7455b3f175821
github
async-runtime
https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/multi_thread/park.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:3
if let Some(mut driver) = self.inner.shared.driver.try_lock() { driver.park_timeout(duration) } } pub(crate) fn shutdown(&mut self) { self.inner.shutdown(); } } impl Clone for Parker { fn clone(&self) -> Parker { Parker { inner: Arc::new(Inner { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
99aa8d12b7ad2ef011a7a9f652f7455b3f175821
github
async-runtime
https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/multi_thread/park.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:4
return; } thread::yield_now(); } if let Some(mut driver) = self.shared.driver.try_lock() { self.park_driver(&mut driver); } else { self.park_condvar(); } } fn park_condvar(&self) { // Otherwise we need to coordinate going...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
99aa8d12b7ad2ef011a7a9f652f7455b3f175821
github
async-runtime
https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/multi_thread/park.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:5
if self .state .compare_exchange(NOTIFIED, EMPTY, SeqCst, SeqCst) .is_ok() { // got a notification return; } // spurious wakeup, go back to sleep } } fn park_driver(&self, driver: &mut D...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
99aa8d12b7ad2ef011a7a9f652f7455b3f175821
github
async-runtime
https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/multi_thread/park.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/park.rs:6
} } fn unpark(&self) { // To ensure the unparked thread will observe any writes we made before // this call, we must perform a release operation that `park` can // synchronize with. To do that we must write `NOTIFIED` even if `state` // is already `NOTIFIED`. That is why this mu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/park.rs
MIT
99aa8d12b7ad2ef011a7a9f652f7455b3f175821
github
async-runtime
https://github.com/tokio-rs/tokio/blob/99aa8d12b7ad2ef011a7a9f652f7455b3f175821/tokio/src/runtime/scheduler/multi_thread/park.rs
201
247
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:1
//! Run-queue structures to support a work-stealing scheduler use crate::loom::cell::UnsafeCell; use crate::loom::sync::Arc; use crate::runtime::scheduler::multi_thread::{Overflow, Stats}; use crate::runtime::task; use std::mem::{self, MaybeUninit}; use std::ptr; use std::sync::atomic::Ordering::{AcqRel, Acquire, Rel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
1
60
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:2
/// of stealing values. It represents the first value being stolen in the /// batch. The `UnsignedShort` indices are intentionally wider than strictly /// required for buffer indexing in order to provide ABA mitigation and make /// it possible to distinguish between full and empty buffers. /// /// W...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:3
unsafe { Box::from_raw(Box::into_raw(buffer).cast()) } } /// Create a new local run-queue pub(crate) fn local<T: 'static>() -> (Steal<T>, Local<T>) { let buffer = std::iter::repeat_with(|| UnsafeCell::new(MaybeUninit::uninit())); let inner = Arc::new(Inner { head: AtomicUnsignedLong::new(0), t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:4
pub(crate) fn max_capacity(&self) -> usize { LOCAL_QUEUE_CAPACITY } /// Returns false if there are any entries in the queue /// /// Separate to `is_stealable` so that refactors of `is_stealable` to "protect" /// some tasks from stealing won't affect this pub(crate) fn has_tasks(&self) -...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:5
for task in tasks { let idx = tail as usize & MASK; self.inner.buffer[idx].with_mut(|ptr| { // Write the task to the slot // // Safety: There is only one producer and the above `if` // condition ensures we don't touch a cell if the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:6
if tail.wrapping_sub(steal) < LOCAL_QUEUE_CAPACITY as UnsignedShort { // There is capacity for the task break tail; } else if steal != real { // Concurrently stealing, this will free up capacity, so only // push the task onto the inject queue ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
201
260
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:7
// Make the task available. Synchronizes with a load in // `steal_into2`. self.inner.tail.store(tail.wrapping_add(1), Release); } /// Moves a batch of tasks into the inject queue. /// /// This will temporarily make some of the tasks unavailable to stealers. /// Once `push_overflow` ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
241
300
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:8
// current thread (or memory has been acquired if the local queue handle // moved). if self .inner .head .compare_exchange_weak(pack(head, head), pack(tail, tail), Release, Relaxed) .is_err() { // We failed to claim the tasks, losing th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
281
340
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:9
head: UnsignedLong, i: UnsignedLong, } impl<'a, T: 'static> Iterator for BatchTaskIter<'a, T> { type Item = task::Notified<T>; #[inline] fn next(&mut self) -> Option<task::Notified<T>> { if self.i == UnsignedLong::from(NUM_TASKS_TAKEN) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
321
380
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:10
pub(crate) fn pop(&mut self) -> Option<task::Notified<T>> { let mut head = self.inner.head.load(Acquire); let idx = loop { let (steal, real) = unpack(head); // safety: this is the **only** thread that updates this cell. let tail = unsafe { self.inner.tail.unsync_loa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
361
420
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:11
impl<T> Steal<T> { /// Returns the number of entries in the queue pub(crate) fn len(&self) -> usize { let (_, head) = unpack(self.0.head.load(Acquire)); let tail = self.0.tail.load(Acquire); len(head, tail) } /// Return true if the queue is empty, /// false if there are any ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
401
460
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:12
if n == 0 { // No tasks were stolen return None; } dst_stats.incr_steal_count(n as u16); dst_stats.incr_steal_operations(); // We are returning a task here n -= 1; let ret_pos = dst_tail.wrapping_add(n); let ret_idx = ret_pos as usize & ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
441
500
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:13
// stealing from the queue. if src_head_steal != src_head_real { return 0; } // Number of available tasks to steal let n = src_tail.wrapping_sub(src_head_real); let n = n - n / 2; if n == 0 { // No tasks available ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
481
540
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:14
// Take all the tasks for i in 0..n { // Compute the positions let src_pos = first.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; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
521
580
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:15
} } } impl<T> Clone for Steal<T> { fn clone(&self) -> Steal<T> { Steal(self.0.clone()) } } impl<T> Drop for Local<T> { fn drop(&mut self) { if !std::thread::panicking() { assert!(self.pop().is_none(), "queue not empty"); } } } /// Calculate the length of the qu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/scheduler/multi_thread/queue.rs
561
602
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:2
/// of stealing values. It represents the first value being stolen in the /// batch. The `UnsignedShort` indices are intentionally wider than strictly /// required for buffer indexing in order to provide ABA mitigation and make /// it possible to distinguish between full and empty buffers. /// /// W...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:3
unsafe { Box::from_raw(Box::into_raw(buffer).cast()) } } /// Create a new local run-queue pub(crate) fn local<T: 'static>() -> (Steal<T>, Local<T>) { let mut buffer = Vec::with_capacity(LOCAL_QUEUE_CAPACITY); for _ in 0..LOCAL_QUEUE_CAPACITY { buffer.push(UnsafeCell::new(MaybeUninit::uninit())); }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:4
LOCAL_QUEUE_CAPACITY - len(steal, tail) } pub(crate) fn max_capacity(&self) -> usize { LOCAL_QUEUE_CAPACITY } /// Returns false if there are any entries in the queue /// /// Separate to `is_stealable` so that refactors of `is_stealable` to "protect" /// some tasks from stealing won...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:5
// `push_back_or_overflow`. } else { panic!() } for task in tasks { let idx = tail as usize & MASK; self.inner.buffer[idx].with_mut(|ptr| { // Write the task to the slot // // Safety: There is only one producer...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:6
// safety: this is the **only** thread that updates this cell. let tail = unsafe { self.inner.tail.unsync_load() }; if tail.wrapping_sub(steal) < LOCAL_QUEUE_CAPACITY as UnsignedShort { // There is capacity for the task break tail; } else if steal != ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
201
260
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:7
ptr::write((*ptr).as_mut_ptr(), task); } }); // Make the task available. Synchronizes with a load in // `steal_into2`. self.inner.tail.store(tail.wrapping_add(1), Release); } /// Moves a batch of tasks into the inject queue. /// /// This will temporarily mak...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
241
300
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:8
// We are claiming the tasks **before** reading them out of the buffer. // This is safe because only the **current** thread is able to push new // tasks. // // There isn't really any need for memory ordering... Relaxed would // work. This is because all tasks are pushed into the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
281
340
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:9
None } else { let i_idx = self.i.wrapping_add(self.head) as usize & MASK; let slot = &self.buffer[i_idx]; // safety: Our CAS from before has assumed exclusive ownership // of the task pointers in this range. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
321
380
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:10
if real == tail { // queue is empty return None; } let next_real = real.wrapping_add(1); // If `steal == real` there are no concurrent stealers. Both `steal` // and `real` are updated. let next = if steal == real { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
361
420
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:11
/// Return true if the queue is empty, /// false if there are any entries in the queue pub(crate) fn is_empty(&self) -> bool { self.len() == 0 } /// Steals half the tasks from self and place them into `dst`. pub(crate) fn steal_into( &self, dst: &mut Local<T>, dst_st...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
401
460
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:12
n -= 1; let ret_pos = dst_tail.wrapping_add(n); let ret_idx = ret_pos as usize & MASK; // safety: the value was written as part of `steal_into2` and not // exposed to stealers, so no other thread can access it. let ret = dst.inner.buffer[ret_idx].with(|ptr| unsafe { ptr::read((...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
441
500
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:13
if n == 0 { // No tasks available to steal return 0; } // Update the real head index to acquire the tasks. let steal_to = src_head_real.wrapping_add(n); assert_ne!(src_head_steal, steal_to); next_packed = pack(src_head_steal, s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
481
540
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:14
// Read the task // // safety: We acquired the task with the atomic exchange above. let task = self.0.buffer[src_idx].with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) }); // Write the task to the new slot // // safety: `dst` queue is empty and we ar...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
521
580
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:15
impl<T> Clone for Steal<T> { fn clone(&self) -> Steal<T> { Steal(self.0.clone()) } } impl<T> Drop for Local<T> { fn drop(&mut self) { if !std::thread::panicking() { assert!(self.pop().is_none(), "queue not empty"); } } } /// Calculate the length of the queue using t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
967f5715a71d5d2600b71da8c4ab652c4e644a41
github
async-runtime
https://github.com/tokio-rs/tokio/blob/967f5715a71d5d2600b71da8c4ab652c4e644a41/tokio/src/runtime/scheduler/multi_thread/queue.rs
561
599
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:1
//! Run-queue structures to support a work-stealing scheduler use crate::loom::cell::UnsafeCell; use crate::loom::sync::Arc; use crate::runtime::scheduler::multi_thread::{Overflow, Stats}; use crate::runtime::task; use std::mem::{self, MaybeUninit}; use std::ptr; use std::sync::atomic::Ordering::{AcqRel, Acquire, Rel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
1
60
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:2
/// of stealing values. It represents the first value being stolen in the /// batch. The `UnsignedShort` indices are intentionally wider than strictly /// required for buffer indexing in order to provide ABA mitigation and make /// it possible to distinguish between full and empty buffers. /// /// W...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:3
// do it is to repeat `UnsafeCell::new(MaybeUninit::uninit())` 256 times, as // the contents are not Copy. The trick with defining a const doesn't work for // generic types. fn make_fixed_size<T>(buffer: Box<[T]>) -> Box<[T; LOCAL_QUEUE_CAPACITY]> { assert_eq!(buffer.len(), LOCAL_QUEUE_CAPACITY); // safety: We...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:4
/// How many tasks can be pushed into the queue pub(crate) fn remaining_slots(&self) -> usize { let (steal, _) = unpack(self.inner.head.load(Acquire)); // safety: this is the **only** thread that updates this cell. let tail = unsafe { self.inner.tail.unsync_load() }; LOCAL_QUEUE_CAP...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:5
let mut tail = unsafe { self.inner.tail.unsync_load() }; if tail.wrapping_sub(steal) <= (LOCAL_QUEUE_CAPACITY - len) as UnsignedShort { // Yes, this if condition is structured a bit weird (first block // does nothing, second returns an error). It is this way to match // `pus...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:6
stats: &mut Stats, ) { let tail = loop { let head = self.inner.head.load(Acquire); let (steal, real) = unpack(head); // safety: this is the **only** thread that updates this cell. let tail = unsafe { self.inner.tail.unsync_load() }; if tail.wrapp...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
201
260
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:7
// // Safety: There is only one producer and the above `if` // condition ensures we don't touch a cell if there is a // value, thus no consumer. unsafe { ptr::write((*ptr).as_mut_ptr(), task); } }); // Make the task available. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
241
300
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:8
// Claim all tasks. // // We are claiming the tasks **before** reading them out of the buffer. // This is safe because only the **current** thread is able to push new // tasks. // // There isn't really any need for memory ordering... Relaxed would // work. This is...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
281
340
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:9
// tasks we are adding to the injection queue instead, which ensures that the stealer wakes // up again to take the tasks from the injection queue. self.inner .tail .store(tail.wrapping_add(NUM_TASKS_TAKEN), Release); /// An iterator that takes elements out of the run qu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
321
380
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:10
overflow.push_batch(batch_iter.chain(std::iter::once(task))); // Add 1 to factor in the task currently being scheduled. stats.incr_overflow_count(); Ok(()) } /// Pops a task from the local queue. pub(crate) fn pop(&mut self) -> Option<task::Notified<T>> { let mut head = se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
361
420
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:11
match res { Ok(_) => break real as usize & MASK, Err(actual) => head = actual, } }; Some(self.inner.buffer[idx].with(|ptr| unsafe { ptr::read(ptr).assume_init() })) } /// Pushes a task to the LIFO slot, returning the task previously in the /// LI...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
401
460
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:12
&self, dst: &mut Local<T>, dst_stats: &mut Stats, ) -> Option<task::Notified<T>> { // Safety: the caller is the only thread that mutates `dst.tail` and // holds a mutable reference. let dst_tail = unsafe { dst.inner.tail.unsync_load() }; // To the caller, `dst` may *...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
441
500
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:13
let ret_pos = dst_tail.wrapping_add(n); let ret_idx = ret_pos as usize & MASK; // safety: the value was written as part of `steal_into2` and not // exposed to stealers, so no other thread can access it. let ret = dst.inner.buffer[ret_idx].with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
481
540
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:14
return 0; } // Update the real head index to acquire the tasks. let steal_to = src_head_real.wrapping_add(n); assert_ne!(src_head_steal, steal_to); next_packed = pack(src_head_steal, steal_to); // Claim all those tasks. This is done by incrementi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
521
580
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:15
// // safety: We acquired the task with the atomic exchange above. let task = self.0.buffer[src_idx].with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) }); // Write the task to the new slot // // safety: `dst` queue is empty and we are the only producer to ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
561
620
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:16
fn drop(&mut self) { if !std::thread::panicking() { assert!(self.pop().is_none(), "queue not empty"); assert!(self.pop_lifo().is_none(), "LIFO slot not empty"); } } } /// Calculate the length of the queue using the head and tail. /// The `head` can be the `steal` or `real` h...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
26dee92b535d0a204531b6a04ee761f06c402d7e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/26dee92b535d0a204531b6a04ee761f06c402d7e/tokio/src/runtime/scheduler/multi_thread/queue.rs
601
632
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:2
/// of stealing values. It represents the first value being stolen in the /// batch. The `UnsignedShort` indices are intentionally wider than strictly /// required for buffer indexing in order to provide ABA mitigation and make /// it possible to distinguish between full and empty buffers. /// /// W...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
41
100
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:3
// do it is to repeat `UnsafeCell::new(MaybeUninit::uninit())` 256 times, as // the contents are not Copy. The trick with defining a const doesn't work for // generic types. fn make_fixed_size<T>(buffer: Box<[T]>) -> Box<[T; LOCAL_QUEUE_CAPACITY]> { assert_eq!(buffer.len(), LOCAL_QUEUE_CAPACITY); // safety: We...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
81
140
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:4
let tail = unsafe { self.inner.tail.unsync_load() }; len(head, tail) + lifo } /// How many tasks can be pushed into the queue pub(crate) fn remaining_slots(&self) -> usize { let (steal, _) = unpack(self.inner.head.load(Acquire)); // safety: this is the **only** thread that updates t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
121
180
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:5
let head = self.inner.head.load(Acquire); let (steal, _) = unpack(head); // safety: this is the **only** thread that updates this cell. let mut tail = unsafe { self.inner.tail.unsync_load() }; if tail.wrapping_sub(steal) <= (LOCAL_QUEUE_CAPACITY - len) as UnsignedShort { //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
161
220
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:6
pub(crate) fn push_back_or_overflow<O: Overflow<T>>( &mut self, mut task: task::Notified<T>, overflow: &O, stats: &mut Stats, ) { let tail = loop { let head = self.inner.head.load(Acquire); let (steal, real) = unpack(head); // safety: this...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
201
260
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:7
let idx = tail as usize & MASK; self.inner.buffer[idx].with_mut(|ptr| { // Write the task to the slot // // Safety: There is only one producer and the above `if` // condition ensures we don't touch a cell if there is a // value, thus no consumer. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
241
300
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:8
tail.wrapping_sub(head) as usize, LOCAL_QUEUE_CAPACITY, "queue is not full; tail = {tail}; head = {head}" ); // Claim all tasks. // // We are claiming the tasks **before** reading them out of the buffer. // This is safe because only the **current** thread...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
281
340
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:9
// Note that if a concurrent worker tries to steal from us between these two operations and // sees that the worker queue is empty, then that worker may go to sleep, and we do not // notify it about these tasks becoming available for stealing again. Ordinarily this would // be a problem, but it ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
321
380
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:10
buffer: &self.inner.buffer, head: head.wrapping_add(NUM_TASKS_TAKEN) as UnsignedLong, i: 0, }; overflow.push_batch(batch_iter.chain(std::iter::once(task))); // Add 1 to factor in the task currently being scheduled. stats.incr_overflow_count(); Ok(()) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
361
420
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:11
.inner .head .compare_exchange_weak(head, next, AcqRel, Acquire); match res { Ok(_) => break real as usize & MASK, Err(actual) => head = actual, } }; Some(self.inner.buffer[idx].with(|ptr| unsafe { ptr::read(ptr).a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
401
460
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:12
} /// Steals half the tasks from self and place them into `dst`. pub(crate) fn steal_into( &self, dst: &mut Local<T>, dst_stats: &mut Stats, ) -> Option<task::Notified<T>> { // Safety: the caller is the only thread that mutates `dst.tail` and // holds a mutable refer...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
441
500
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:13
// We are returning a task here n -= 1; let ret_pos = dst_tail.wrapping_add(n); let ret_idx = ret_pos as usize & MASK; // safety: the value was written as part of `steal_into2` and not // exposed to stealers, so no other thread can access it. let ret = dst.inner.buffer[...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
481
540
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:14
let n = n - n / 2; if n == 0 { // No tasks available to steal return 0; } // Update the real head index to acquire the tasks. let steal_to = src_head_real.wrapping_add(n); assert_ne!(src_head_steal, steal_to); next...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
521
580
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:15
let src_idx = src_pos as usize & MASK; let dst_idx = dst_pos as usize & MASK; // Read the task // // safety: We acquired the task with the atomic exchange above. let task = self.0.buffer[src_idx].with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) }); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
561
620
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:16
} } impl<T> Drop for Local<T> { fn drop(&mut self) { if !std::thread::panicking() { assert!(self.pop().is_none(), "queue not empty"); assert!(self.pop_lifo().is_none(), "LIFO slot not empty"); } } } /// Calculate the length of the queue using the head and tail. /// The ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
203af021261ab7399c18ab12f22c24f1934c7d42
github
async-runtime
https://github.com/tokio-rs/tokio/blob/203af021261ab7399c18ab12f22c24f1934c7d42/tokio/src/runtime/scheduler/multi_thread/queue.rs
601
636
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:7
let idx = tail as usize & MASK; self.inner.buffer[idx].with_mut(|ptr| { // Write the task to the slot // // Safety: There is only one producer and the above `if` // condition ensures we don't touch a cell if there is a // value, thus no consumer. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c/tokio/src/runtime/scheduler/multi_thread/queue.rs
241
300
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:8
tail.wrapping_sub(head) as usize, LOCAL_QUEUE_CAPACITY, "queue is not full; tail = {tail}; head = {head}" ); let prev = pack(head, head); // Claim a bunch of tasks // // We are claiming the tasks **before** reading them out of the buffer. // This...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c/tokio/src/runtime/scheduler/multi_thread/queue.rs
281
340
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:9
head: UnsignedLong, i: UnsignedLong, } impl<'a, T: 'static> Iterator for BatchTaskIter<'a, T> { type Item = task::Notified<T>; #[inline] fn next(&mut self) -> Option<task::Notified<T>> { if self.i == UnsignedLong::from(NUM_TASKS_TAKEN) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c/tokio/src/runtime/scheduler/multi_thread/queue.rs
321
380
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:10
pub(crate) fn pop(&mut self) -> Option<task::Notified<T>> { let mut head = self.inner.head.load(Acquire); let idx = loop { let (steal, real) = unpack(head); // safety: this is the **only** thread that updates this cell. let tail = unsafe { self.inner.tail.unsync_loa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c/tokio/src/runtime/scheduler/multi_thread/queue.rs
361
420
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:11
/// Pushes a task to the LIFO slot, returning the task previously in the /// LIFO slot (if there was one). pub(crate) fn push_lifo(&self, task: task::Notified<T>) -> Option<task::Notified<T>> { self.inner.lifo.swap(Some(task)) } /// Pops the task currently held in the LIFO slot, if there is one...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c/tokio/src/runtime/scheduler/multi_thread/queue.rs
401
460
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:12
// contained in the buffer. If another thread is concurrently stealing // from `dst` there may not be enough capacity to steal. let (steal, _) = unpack(dst.inner.head.load(Acquire)); if dst_tail.wrapping_sub(steal) > LOCAL_QUEUE_CAPACITY as UnsignedShort / 2 { // we *could* try to s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c/tokio/src/runtime/scheduler/multi_thread/queue.rs
441
500
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:13
return Some(ret); } // Make the stolen items available to consumers dst.inner.tail.store(dst_tail.wrapping_add(n), Release); Some(ret) } // Steal tasks from `self`, placing them into `dst`. Returns the number of // tasks that were stolen. fn steal_into2(&self, dst: &mu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c/tokio/src/runtime/scheduler/multi_thread/queue.rs
481
540
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:14
// head but not the steal. By doing this, no other thread is able to // steal from this queue until the current thread completes. let res = self .0 .head .compare_exchange_weak(prev_packed, next_packed, AcqRel, Acquire); match res { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c/tokio/src/runtime/scheduler/multi_thread/queue.rs
521
580
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:15
.with_mut(|ptr| unsafe { ptr::write((*ptr).as_mut_ptr(), task) }); } let mut prev_packed = next_packed; // Update `src_head_steal` to match `src_head_real` signalling that the // stealing routine is complete. loop { let head = unpack(prev_packed).1; next...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c/tokio/src/runtime/scheduler/multi_thread/queue.rs
561
620
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:16
/// The `head` can be the `steal` or `real` head. fn len(head: UnsignedShort, tail: UnsignedShort) -> usize { tail.wrapping_sub(head) as usize } /// Split the head value into the real head and the index a stealer is working /// on. fn unpack(n: UnsignedLong) -> (UnsignedShort, UnsignedShort) { let real = n & U...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4c7d8b2a14de81ace4d8e61cfaeb8eca26f6f68c/tokio/src/runtime/scheduler/multi_thread/queue.rs
601
623
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:8
tail.wrapping_sub(head) as usize, LOCAL_QUEUE_CAPACITY, "queue is not full; tail = {tail}; head = {head}" ); let prev = pack(head, head); // Claim a bunch of tasks // // We are claiming the tasks **before** reading them out of the buffer. // This...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/scheduler/multi_thread/queue.rs
281
340
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:10
pub(crate) fn pop(&mut self) -> Option<task::Notified<T>> { let mut head = self.inner.head.load(Acquire); let idx = loop { let (steal, real) = unpack(head); // safety: this is the **only** thread that updates this cell. let tail = unsafe { self.inner.tail.unsync_loa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/scheduler/multi_thread/queue.rs
361
420
tokio-rs/tokio:tokio/src/runtime/scheduler/multi_thread/queue.rs:13
return Some(ret); } // Make the stolen items available to consumers dst.inner.tail.store(dst_tail.wrapping_add(n), Release); Some(ret) } // Steal tasks from `self`, placing them into `dst`. Returns the number of // tasks that were stolen. fn steal_into2(&self, dst: &mu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/scheduler/multi_thread/queue.rs
MIT
eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/eeb55c733ba9a83c51d08b1629dca6a5ec0f4b2b/tokio/src/runtime/scheduler/multi_thread/queue.rs
481
540