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/queue.rs:15
p.tail = Some(batch_tail); // Increment the count. // // safety: All updates to the len atomic are guarded by the mutex. As // such, a non-atomic load followed by a store is safe. let len = unsafe { self.len.unsync_load() }; self.len.store(len + num, Release); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
a39e6c2439927ed9c73043401959b0b02d054630
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a39e6c2439927ed9c73043401959b0b02d054630/tokio/src/runtime/queue.rs
561
620
tokio-rs/tokio:tokio/src/runtime/queue.rs:16
Some(unsafe { task::Notified::from_raw(task) }) } } impl<T: 'static> Drop for Inject<T> { fn drop(&mut self) { if !std::thread::panicking() { assert!(self.pop().is_none(), "queue not empty"); } } } fn get_next(header: NonNull<task::Header>) -> Option<NonNull<task::Header>> { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
a39e6c2439927ed9c73043401959b0b02d054630
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a39e6c2439927ed9c73043401959b0b02d054630/tokio/src/runtime/queue.rs
601
640
tokio-rs/tokio:tokio/src/runtime/queue.rs:3
/// Create a new local run-queue pub(super) 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())); } let inner = Arc::new(Inner { head: AtomicU32...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
81
140
tokio-rs/tokio:tokio/src/runtime/queue.rs:4
// There is capacity for the task break tail; } else if steal != real { // Concurrently stealing, this will free up capacity, so // only push the new task onto the inject queue inject.push(task); return; } else { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
121
180
tokio-rs/tokio:tokio/src/runtime/queue.rs:5
/// /// 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. #[inline(never)] fn push_overflow( &mut se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
161
220
tokio-rs/tokio:tokio/src/runtime/queue.rs:6
prev, pack(head.wrapping_add(n), head.wrapping_add(n)), Release, Relaxed, ) .is_err() { // We failed to claim the tasks, losing the race. Return out of // this function and try the full `push` routine again. The queu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
201
260
tokio-rs/tokio:tokio/src/runtime/queue.rs:7
// safety: the above CAS prevents a stealer from accessing these tasks // and we are the only producer. let head = self.inner.buffer[head as usize & MASK] .with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) }); // Push the tasks onto the inject queue inject.push_batch(head, task...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
241
300
tokio-rs/tokio:tokio/src/runtime/queue.rs:8
.inner .head .compare_exchange(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).assume...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
281
340
tokio-rs/tokio:tokio/src/runtime/queue.rs:9
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; // safety: the value was written as part of `steal_into2` and not /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
321
380
tokio-rs/tokio:tokio/src/runtime/queue.rs:10
} // 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 to steal return 0; } // Update the real head index to acquire the tasks. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
361
420
tokio-rs/tokio:tokio/src/runtime/queue.rs:11
// Map to slots 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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
401
460
tokio-rs/tokio:tokio/src/runtime/queue.rs:12
} } } 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"); } } } impl<T> Inner<T> { fn is_empty...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
441
500
tokio-rs/tokio:tokio/src/runtime/queue.rs:13
pub(super) fn is_empty(&self) -> bool { self.len() == 0 } /// Close the injection queue, returns `true` if the queue is open when the /// transition is made. pub(super) fn close(&self) -> bool { let mut p = self.pointers.lock(); if p.is_closed { return false; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
481
540
tokio-rs/tokio:tokio/src/runtime/queue.rs:14
let task = task.into_raw(); // The next pointer should already be null debug_assert!(get_next(task).is_none()); if let Some(tail) = p.tail { set_next(tail, Some(task)); } else { p.head = Some(task); } p.tail = Some(task); self.len.store...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
521
580
tokio-rs/tokio:tokio/src/runtime/queue.rs:15
// such, a non-atomic load followed by a store is safe. let len = unsafe { self.len.unsync_load() }; self.len.store(len + num, Release); } pub(super) fn pop(&self) -> Option<task::Notified<T>> { // Fast path, if len == 0, then there are no values if self.is_empty() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
561
620
tokio-rs/tokio:tokio/src/runtime/queue.rs:16
if !std::thread::panicking() { assert!(self.pop().is_none(), "queue not empty"); } } } fn get_next(header: NonNull<task::Header>) -> Option<NonNull<task::Header>> { unsafe { header.as_ref().queue_next.with(|ptr| *ptr) } } fn set_next(header: NonNull<task::Header>, val: Option<NonNull<task:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
f3ed064a269fd72711e40121dad1a9fd9f16bdc0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/queue.rs
601
634
tokio-rs/tokio:tokio/src/runtime/queue.rs:15
// such, a non-atomic load followed by a store is safe. let len = unsafe { self.len.unsync_load() }; self.len.store(len + num, Release); } pub(super) fn pop(&self) -> Option<task::Notified<T>> { // Fast path, if len == 0, then there are no values if self.is_empty() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/runtime/queue.rs
561
620
tokio-rs/tokio:tokio/src/runtime/queue.rs:16
if !std::thread::panicking() { assert!(self.pop().is_none(), "queue not empty"); } } } fn get_next(header: NonNull<task::Header>) -> Option<NonNull<task::Header>> { unsafe { header.as_ref().queue_next.with(|ptr| *ptr) } } fn set_next(header: NonNull<task::Header>, val: Option<NonNull<task:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
9a3603fa75ff854e007d372061edf47cf8d02690
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9a3603fa75ff854e007d372061edf47cf8d02690/tokio/src/runtime/queue.rs
601
634
tokio-rs/tokio:tokio/src/runtime/queue.rs:14
let task = task.into_raw(); // The next pointer should already be null debug_assert!(get_next(task).is_none()); if let Some(tail) = p.tail { set_next(tail, Some(task)); } else { p.head = Some(task); } p.tail = Some(task); self.len.store...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
6f988728bb1b9156b78153461c8632e44cb21a21
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f988728bb1b9156b78153461c8632e44cb21a21/tokio/src/runtime/queue.rs
521
580
tokio-rs/tokio:tokio/src/runtime/queue.rs:15
// such, a non-atomic load followed by a store is safe. let len = unsafe { self.len.unsync_load() }; self.len.store(len + num, Release); } pub(super) fn pop(&self) -> Option<task::Notified<T>> { // Fast path, if len == 0, then there are no values if self.is_empty() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
6f988728bb1b9156b78153461c8632e44cb21a21
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6f988728bb1b9156b78153461c8632e44cb21a21/tokio/src/runtime/queue.rs
561
620
tokio-rs/tokio:tokio/src/runtime/queue.rs:6
prev, pack(head.wrapping_add(n), head.wrapping_add(n)), Release, Relaxed, ) .is_err() { // We failed to claim the tasks, losing the race. Return out of // this function and try the full `push` routine again. The queu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
770044caa70465fbe5d2851a8d9a0bc0e5e7429a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/770044caa70465fbe5d2851a8d9a0bc0e5e7429a/tokio/src/runtime/queue.rs
201
260
tokio-rs/tokio:tokio/src/runtime/queue.rs:15
// such, a non-atomic load followed by a store is safe. let len = unsafe { self.len.unsync_load() }; self.len.store(len + num, Release); } pub(super) fn pop(&self) -> Option<task::Notified<T>> { // Fast path, if len == 0, then there are no values if self.is_empty() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
770044caa70465fbe5d2851a8d9a0bc0e5e7429a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/770044caa70465fbe5d2851a8d9a0bc0e5e7429a/tokio/src/runtime/queue.rs
561
620
tokio-rs/tokio:tokio/src/runtime/queue.rs:16
if !std::thread::panicking() { assert!(self.pop().is_none(), "queue not empty"); } } } fn get_next(header: NonNull<task::Header>) -> Option<NonNull<task::Header>> { unsafe { header.as_ref().queue_next.with(|ptr| *ptr) } } fn set_next(header: NonNull<task::Header>, val: Option<NonNull<task:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
770044caa70465fbe5d2851a8d9a0bc0e5e7429a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/770044caa70465fbe5d2851a8d9a0bc0e5e7429a/tokio/src/runtime/queue.rs
601
634
tokio-rs/tokio:tokio/src/runtime/queue.rs:1
//! Run-queue structures to support a work-stealing scheduler use crate::loom::cell::UnsafeCell; use crate::loom::sync::atomic::{AtomicU16, AtomicU32, AtomicUsize}; use crate::loom::sync::{Arc, Mutex}; use crate::runtime::task; use std::marker::PhantomData; use std::mem::MaybeUninit; use std::ptr::{self, NonNull}; us...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/queue.rs
1
60
tokio-rs/tokio:tokio/src/runtime/queue.rs:5
/// /// 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. #[inline(never)] fn push_overflow( &mut se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/queue.rs
161
220
tokio-rs/tokio:tokio/src/runtime/queue.rs:6
); if actual != prev { // We failed to claim the tasks, losing the race. Return out of // 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 { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/queue.rs
201
260
tokio-rs/tokio:tokio/src/runtime/queue.rs:7
.with(|ptr| unsafe { ptr::read((*ptr).as_ptr()) }); // Push the tasks onto the inject queue inject.push_batch(head, task, BATCH_LEN); Ok(()) } /// Pops a task from the local queue. pub(super) fn pop(&mut self) -> Option<task::Notified<T>> { let mut head = self.inner.head.l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/queue.rs
241
300
tokio-rs/tokio:tokio/src/runtime/queue.rs:8
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() })) } } impl<T> Steal<T> { pub(super) fn is_empty(&self) -> bool { self.0.is_empt...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/queue.rs
281
340
tokio-rs/tokio:tokio/src/runtime/queue.rs:12
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"); } } } impl<T> Inner<T> { fn is_empty(&self) -> ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/queue.rs
441
500
tokio-rs/tokio:tokio/src/runtime/queue.rs:13
/// Close the injection queue, returns `true` if the queue is open when the /// transition is made. pub(super) fn close(&self) -> bool { let mut p = self.pointers.lock(); if p.is_closed { return false; } p.is_closed = true; true } pub(super) fn is_c...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/queue.rs
481
540
tokio-rs/tokio:tokio/src/runtime/queue.rs:14
if let Some(tail) = p.tail { set_next(tail, Some(task)); } 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::N...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/queue.rs
521
580
tokio-rs/tokio:tokio/src/runtime/queue.rs:15
} pub(super) fn pop(&self) -> Option<task::Notified<T>> { // Fast path, if len == 0, then there are no values if self.is_empty() { return None; } let mut p = self.pointers.lock(); // It is possible to hit null here if another thread poped the last // ta...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/queue.rs
561
620
tokio-rs/tokio:tokio/src/runtime/queue.rs:16
} fn get_next(header: NonNull<task::Header>) -> Option<NonNull<task::Header>> { unsafe { header.as_ref().queue_next.with(|ptr| *ptr) } } fn set_next(header: NonNull<task::Header>, val: Option<NonNull<task::Header>>) { unsafe { header.as_ref().queue_next.with_mut(|ptr| *ptr = val); } } /// Split t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
444660664b96f758610a0e7201a6a1a31a0f2405
github
async-runtime
https://github.com/tokio-rs/tokio/blob/444660664b96f758610a0e7201a6a1a31a0f2405/tokio/src/runtime/queue.rs
601
630
tokio-rs/tokio:tokio/src/runtime/queue.rs:12
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"); } } } impl<T> Inner<T> { fn is_empty(&self) -> ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
58ba45a38cc101e695895cc39d8ee4ce74176397
github
async-runtime
https://github.com/tokio-rs/tokio/blob/58ba45a38cc101e695895cc39d8ee4ce74176397/tokio/src/runtime/queue.rs
441
500
tokio-rs/tokio:tokio/src/runtime/queue.rs:13
/// Close the injection queue, returns `true` if the queue is open when the /// transition is made. pub(super) fn close(&self) -> bool { let mut p = self.pointers.lock().unwrap(); if p.is_closed { return false; } p.is_closed = true; true } pub(super...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
58ba45a38cc101e695895cc39d8ee4ce74176397
github
async-runtime
https://github.com/tokio-rs/tokio/blob/58ba45a38cc101e695895cc39d8ee4ce74176397/tokio/src/runtime/queue.rs
481
540
tokio-rs/tokio:tokio/src/runtime/queue.rs:14
if let Some(tail) = p.tail { set_next(tail, Some(task)); } 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::N...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
58ba45a38cc101e695895cc39d8ee4ce74176397
github
async-runtime
https://github.com/tokio-rs/tokio/blob/58ba45a38cc101e695895cc39d8ee4ce74176397/tokio/src/runtime/queue.rs
521
580
tokio-rs/tokio:tokio/src/runtime/queue.rs:15
} pub(super) fn pop(&self) -> Option<task::Notified<T>> { // 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 ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
58ba45a38cc101e695895cc39d8ee4ce74176397
github
async-runtime
https://github.com/tokio-rs/tokio/blob/58ba45a38cc101e695895cc39d8ee4ce74176397/tokio/src/runtime/queue.rs
561
620
tokio-rs/tokio:tokio/src/runtime/queue.rs:1
//! Run-queue structures to support a work-stealing scheduler use crate::loom::cell::UnsafeCell; use crate::loom::sync::atomic::{AtomicU16, AtomicU8, AtomicUsize}; use crate::loom::sync::{Arc, Mutex}; use crate::runtime::task; use std::marker::PhantomData; use std::mem::MaybeUninit; use std::ptr::{self, NonNull}; use...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
1
60
tokio-rs/tokio:tokio/src/runtime/queue.rs:2
/// When both `u8` values are the same, there is no active stealer. /// /// Tracking an in-progress stealer prevents a wrapping scenario. head: AtomicU16, /// Only updated by producer thread but read by many threads. tail: AtomicU8, /// Elements buffer: Box<[UnsafeCell<MaybeUninit<task::No...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
41
100
tokio-rs/tokio:tokio/src/runtime/queue.rs:3
pub(super) 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())); } let inner = Arc::new(Inner { head: AtomicU16::new(0), tail: AtomicU8:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
81
140
tokio-rs/tokio:tokio/src/runtime/queue.rs:4
} else if steal != real { // Concurrently stealing, this will free up capacity, so // only push the new 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/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
121
180
tokio-rs/tokio:tokio/src/runtime/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: u8, tail: u8, injec...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
161
220
tokio-rs/tokio:tokio/src/runtime/queue.rs:6
if actual != prev { // We failed to claim the tasks, losing the race. Return out of // 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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
201
260
tokio-rs/tokio:tokio/src/runtime/queue.rs:7
// Push the tasks onto the inject queue inject.push_batch(head, task, BATCH_LEN); Ok(()) } /// Pops a task from the local queue. pub(super) fn pop(&mut self) -> Option<task::Notified<T>> { let mut head = self.inner.head.load(Acquire); let idx = loop { let (stea...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
241
300
tokio-rs/tokio:tokio/src/runtime/queue.rs:8
}; Some(self.inner.buffer[idx].with(|ptr| unsafe { ptr::read(ptr).assume_init() })) } } impl<T> Steal<T> { pub(super) fn is_empty(&self) -> bool { self.0.is_empty() } /// Steals half the tasks from self and place them into `dst`. pub(super) fn steal_into(&self, dst: &mut Local<T>)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
281
340
tokio-rs/tokio:tokio/src/runtime/queue.rs:9
// 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: &mut Local<T>, dst_tail: u8) -> u8 { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
321
380
tokio-rs/tokio:tokio/src/runtime/queue.rs:10
.0 .head .compare_exchange(prev_packed, next_packed, AcqRel, Acquire); match res { Ok(_) => break n, Err(actual) => prev_packed = actual, } }; let (first, _) = unpack(next_packed); // Take all the tasks ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
361
420
tokio-rs/tokio:tokio/src/runtime/queue.rs:11
let head = unpack(prev_packed).1; next_packed = pack(head, head); let res = self .0 .head .compare_exchange(prev_packed, next_packed, AcqRel, Acquire); match res { Ok(_) => return n, Err(actual) => { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
401
460
tokio-rs/tokio:tokio/src/runtime/queue.rs:12
head == tail } } impl<T: 'static> Inject<T> { pub(super) fn new() -> Inject<T> { Inject { pointers: Mutex::new(Pointers { is_closed: false, head: None, tail: None, }), len: AtomicUsize::new(0), _p: PhantomDa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
441
500
tokio-rs/tokio:tokio/src/runtime/queue.rs:13
self.len.load(Acquire) } /// Pushes a value into the queue. pub(super) fn push(&self, task: task::Notified<T>) { // Acquire queue lock let mut p = self.pointers.lock().unwrap(); if p.is_closed { // Drop the mutex to avoid a potential deadlock when // re-ente...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
481
540
tokio-rs/tokio:tokio/src/runtime/queue.rs:14
let batch_head = batch_head.into_raw(); let batch_tail = batch_tail.into_raw(); debug_assert!(get_next(batch_tail).is_none()); let mut p = self.pointers.lock().unwrap(); if let Some(tail) = p.tail { set_next(tail, Some(batch_head)); } else { p.head = So...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
521
580
tokio-rs/tokio:tokio/src/runtime/queue.rs:15
} set_next(task, None); // Decrement the count. // // safety: All updates to the len atomic are guarded by the mutex. As // such, a non-atomic load followed by a store is safe. self.len .store(unsafe { self.len.unsync_load() } - 1, Release); // safe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
561
612
tokio-rs/tokio:tokio/src/runtime/queue.rs:16
(steal as u8, real as u8) } /// Join the two head values fn pack(steal: u8, real: u8) -> u16 { (real as u16) | ((steal as u16) << 8) } #[test] fn test_local_queue_capacity() { assert!(LOCAL_QUEUE_CAPACITY - 1 <= u8::max_value() as usize); }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
fa4fe9ef6feea7c8c88c81559797e57da7368b36
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fa4fe9ef6feea7c8c88c81559797e57da7368b36/tokio/src/runtime/queue.rs
601
612
tokio-rs/tokio:tokio/src/runtime/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: u8, tail: u8, injec...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/queue.rs
161
220
tokio-rs/tokio:tokio/src/runtime/queue.rs:6
if actual != prev { // We failed to claim the tasks, losing the race. Return out of // 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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/queue.rs
201
260
tokio-rs/tokio:tokio/src/runtime/queue.rs:8
}; Some(self.inner.buffer[idx].with(|ptr| unsafe { ptr::read(ptr).assume_init() })) } } impl<T> Steal<T> { pub(super) fn is_empty(&self) -> bool { self.0.is_empty() } /// Steals half the tasks from self and place them into `dst`. pub(super) fn steal_into(&self, dst: &mut Local<T>)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/queue.rs
281
340
tokio-rs/tokio:tokio/src/runtime/queue.rs:9
// Synchronize with stealers let (dst_steal, dst_real) = unpack(dst.inner.head.load(Acquire)); assert_eq!(dst_steal, dst_real); // Make the stolen items available to consumers dst.inner.tail.store(dst_tail.wrapping_add(n), Release); Some(ret) } // Steal tasks from `sel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/queue.rs
321
380
tokio-rs/tokio:tokio/src/runtime/queue.rs:10
// Claim all those tasks. This is done by incrementing the "real" // 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_exchang...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/queue.rs
361
420
tokio-rs/tokio:tokio/src/runtime/queue.rs:11
// Update `src_head_steal` to match `src_head_real` signalling that the // stealing routine is complete. loop { let head = unpack(prev_packed).1; next_packed = pack(head, head); let res = self .0 .head .compare_exchange...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/queue.rs
401
460
tokio-rs/tokio:tokio/src/runtime/queue.rs:12
impl<T> Inner<T> { fn is_empty(&self) -> bool { let (_, head) = unpack(self.head.load(Acquire)); let tail = self.tail.load(Acquire); head == tail } } impl<T: 'static> Inject<T> { pub(super) fn new() -> Inject<T> { Inject { pointers: Mutex::new(Pointers { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/queue.rs
441
500
tokio-rs/tokio:tokio/src/runtime/queue.rs:13
self.pointers.lock().unwrap().is_closed } pub(super) fn len(&self) -> usize { self.len.load(Acquire) } /// Pushes a value into the queue. pub(super) fn push(&self, task: task::Notified<T>) { // Acquire queue lock let mut p = self.pointers.lock().unwrap(); if p.is_c...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/queue.rs
481
540
tokio-rs/tokio:tokio/src/runtime/queue.rs:14
batch_head: task::Notified<T>, batch_tail: task::Notified<T>, num: usize, ) { let batch_head = batch_head.into_raw(); let batch_tail = batch_tail.into_raw(); debug_assert!(get_next(batch_tail).is_none()); let mut p = self.pointers.lock().unwrap(); if let So...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/queue.rs
521
580
tokio-rs/tokio:tokio/src/runtime/queue.rs:15
p.head = get_next(task); if p.head.is_none() { p.tail = None; } set_next(task, None); // Decrement the count. // // safety: All updates to the len atomic are guarded by the mutex. As // such, a non-atomic load followed by a store is safe. se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/queue.rs
561
616
tokio-rs/tokio:tokio/src/runtime/queue.rs:16
fn unpack(n: u16) -> (u8, u8) { let real = n & u8::max_value() as u16; let steal = n >> 8; (steal as u8, real as u8) } /// Join the two head values fn pack(steal: u8, real: u8) -> u16 { (real as u16) | ((steal as u16) << 8) } #[test] fn test_local_queue_capacity() { assert!(LOCAL_QUEUE_CAPACITY -...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/queue.rs
MIT
caa7e180e43fdf914774de86f01f88e6b41f4a32
github
async-runtime
https://github.com/tokio-rs/tokio/blob/caa7e180e43fdf914774de86f01f88e6b41f4a32/tokio/src/runtime/queue.rs
601
616
tokio-rs/tokio:tokio/src/runtime/runtime.rs:1
use super::BOX_FUTURE_THRESHOLD; use crate::runtime::blocking::BlockingPool; use crate::runtime::scheduler::CurrentThread; use crate::runtime::{context, EnterGuard, Handle}; use crate::task::JoinHandle; use crate::util::error::RUNTIME_SHUTTING_DOWN_ERROR; use crate::util::trace::SpawnMeta; use std::future::Future; use...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/runtime.rs
1
60
tokio-rs/tokio:tokio/src/runtime/runtime.rs:3
/// [`Handle::enter`] methods, which use a thread-local variable to store the /// current runtime. Whenever you are inside the runtime context, methods such /// as [`tokio::spawn`] will use the runtime whose context you are inside. /// /// [timer]: crate::time /// [mod]: index.html /// [`new`]: method@Self::new /// [`B...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/runtime.rs
81
140
tokio-rs/tokio:tokio/src/runtime/runtime.rs:4
#[derive(Debug)] pub(super) enum Scheduler { /// Execute all tasks on the current-thread. CurrentThread(CurrentThread), /// Execute tasks across multiple threads. #[cfg(feature = "rt-multi-thread")] MultiThread(MultiThread), } impl Runtime { pub(super) fn from_parts( scheduler: Schedul...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/runtime.rs
121
180
tokio-rs/tokio:tokio/src/runtime/runtime.rs:6
pub fn handle(&self) -> &Handle { &self.handle } /// Spawns a future onto the Tokio runtime. /// /// This spawns the given future onto the runtime's executor, usually a /// thread pool. The thread pool is then responsible for polling the future /// until it completes. /// /// Th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/runtime.rs
201
260
tokio-rs/tokio:tokio/src/runtime/runtime.rs:7
F: Future + Send + 'static, F::Output: Send + 'static, { let fut_size = mem::size_of::<F>(); if fut_size > BOX_FUTURE_THRESHOLD { self.handle .spawn_named(Box::pin(future), SpawnMeta::new_unnamed(fut_size)) } else { self.handle ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/runtime.rs
241
300
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9
/// # Examples /// /// ```no_run /// # #[cfg(not(target_family = "wasm"))] /// # { /// use tokio::runtime::Runtime; /// /// // Create the runtime /// let rt = Runtime::new().unwrap(); /// /// // Execute the future, blocking the current thread until completion /// rt.block_on...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/runtime.rs
321
380
tokio-rs/tokio:tokio/src/runtime/runtime.rs:10
let future = crate::util::trace::task( future, "block_on", _meta, crate::runtime::task::Id::next().as_u64(), ); let _enter = self.enter(); match &self.scheduler { Scheduler::CurrentThread(exec) => exec.block_on(&self.handle.inner, fut...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/runtime.rs
361
420
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12
/// thread::sleep(Duration::from_secs(10_000)); /// }); /// }); /// /// runtime.shutdown_timeout(Duration::from_millis(100)); /// } /// # } /// ``` pub fn shutdown_timeout(mut self, duration: Duration) { // Wakeup and shutdown all the worker threads ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/runtime.rs
441
500
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13
/// inner_runtime.shutdown_background(); /// }); /// } /// # } /// ``` pub fn shutdown_background(self) { self.shutdown_timeout(Duration::from_nanos(0)); } /// Returns a view that lets you get information about how the runtime /// is performing. pub fn metrics(&sel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/runtime.rs
481
540
tokio-rs/tokio:tokio/src/runtime/runtime.rs:14
use std::fmt::Write; struct FormatEq<'r> { remainder: &'r str, unequal: bool, } impl<'r> Write for FormatEq<'r> { fn write_str(&mut self, s: &str) -> std::fmt::Result { if !self.unequal { if let Some(new_remainder) = self.remainder.strip_prefix(s) { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/runtime.rs
521
580
tokio-rs/tokio:tokio/src/runtime/runtime.rs:15
/// let rt2 = Runtime::new().unwrap(); /// /// let listener = rt1.block_on(async { /// TcpListener::bind("127.0.0.1:0").await.unwrap() /// }); /// /// drop(rt1); /// /// rt2.block_on(async { /// let res = listener.accept().await; /// assert!(res.is_err()); /// assert!...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/runtime.rs
561
585
tokio-rs/tokio:tokio/src/runtime/runtime.rs:6
pub fn handle(&self) -> &Handle { &self.handle } /// Spawns a future onto the Tokio runtime. /// /// This spawns the given future onto the runtime's executor, usually a /// thread pool. The thread pool is then responsible for polling the future /// until it completes. /// /// Th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
d65165f7b563d75db110f8ca26b5a4ae749c59e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d65165f7b563d75db110f8ca26b5a4ae749c59e7/tokio/src/runtime/runtime.rs
201
260
tokio-rs/tokio:tokio/src/runtime/runtime.rs:7
F::Output: Send + 'static, { let fut_size = mem::size_of::<F>(); if fut_size > BOX_FUTURE_THRESHOLD { self.handle .spawn_named(Box::pin(future), SpawnMeta::new_unnamed(fut_size)) } else { self.handle .spawn_named(future, SpawnMeta::new_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
d65165f7b563d75db110f8ca26b5a4ae749c59e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d65165f7b563d75db110f8ca26b5a4ae749c59e7/tokio/src/runtime/runtime.rs
241
300
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9
/// /// ```no_run /// # #[cfg(not(target_family = "wasm"))] /// # { /// use tokio::runtime::Runtime; /// /// // Create the runtime /// let rt = Runtime::new().unwrap(); /// /// // Execute the future, blocking the current thread until completion /// rt.block_on(async { /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
d65165f7b563d75db110f8ca26b5a4ae749c59e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d65165f7b563d75db110f8ca26b5a4ae749c59e7/tokio/src/runtime/runtime.rs
321
380
tokio-rs/tokio:tokio/src/runtime/runtime.rs:10
future, "block_on", _meta, crate::runtime::task::Id::next().as_u64(), ); let _enter = self.enter(); match &self.scheduler { Scheduler::CurrentThread(exec) => exec.block_on(&self.handle.inner, future), #[cfg(feature = "rt-multi-thread"...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
d65165f7b563d75db110f8ca26b5a4ae749c59e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d65165f7b563d75db110f8ca26b5a4ae749c59e7/tokio/src/runtime/runtime.rs
361
420
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12
/// }); /// }); /// /// runtime.shutdown_timeout(Duration::from_millis(100)); /// } /// # } /// ``` pub fn shutdown_timeout(mut self, duration: Duration) { // Wakeup and shutdown all the worker threads self.handle.inner.shutdown(); self.blocking_pool.shut...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
d65165f7b563d75db110f8ca26b5a4ae749c59e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d65165f7b563d75db110f8ca26b5a4ae749c59e7/tokio/src/runtime/runtime.rs
441
500
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13
/// }); /// } /// # } /// ``` pub fn shutdown_background(self) { self.shutdown_timeout(Duration::from_nanos(0)); } /// Returns a view that lets you get information about how the runtime /// is performing. pub fn metrics(&self) -> crate::runtime::RuntimeMetrics { self....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
d65165f7b563d75db110f8ca26b5a4ae749c59e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d65165f7b563d75db110f8ca26b5a4ae749c59e7/tokio/src/runtime/runtime.rs
481
540
tokio-rs/tokio:tokio/src/runtime/runtime.rs:14
struct FormatEq<'r> { remainder: &'r str, unequal: bool, } impl<'r> Write for FormatEq<'r> { fn write_str(&mut self, s: &str) -> std::fmt::Result { if !self.unequal { if let Some(new_remainder) = self.remainder.strip_prefix(s) { self.remai...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
d65165f7b563d75db110f8ca26b5a4ae749c59e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d65165f7b563d75db110f8ca26b5a4ae749c59e7/tokio/src/runtime/runtime.rs
521
580
tokio-rs/tokio:tokio/src/runtime/runtime.rs:15
/// /// let listener = rt1.block_on(async { /// TcpListener::bind("127.0.0.1:0").await.unwrap() /// }); /// /// drop(rt1); /// /// rt2.block_on(async { /// let res = listener.accept().await; /// assert!(res.is_err()); /// assert!(tokio::runtime::is_rt_shutdown_err(res.as_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
d65165f7b563d75db110f8ca26b5a4ae749c59e7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d65165f7b563d75db110f8ca26b5a4ae749c59e7/tokio/src/runtime/runtime.rs
561
584
tokio-rs/tokio:tokio/src/runtime/runtime.rs:3
/// as [`tokio::spawn`] will use the runtime whose context you are inside. /// /// [timer]: crate::time /// [mod]: index.html /// [`new`]: method@Self::new /// [`Builder`]: struct@Builder /// [`Handle`]: struct@Handle /// [main]: macro@crate::main /// [`tokio::spawn`]: crate::spawn /// [`Arc::try_unwrap`]: std::sync::A...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c03a37fa0b88ec20df22bec2b035852fd1eab44e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c03a37fa0b88ec20df22bec2b035852fd1eab44e/tokio/src/runtime/runtime.rs
81
140
tokio-rs/tokio:tokio/src/runtime/runtime.rs:4
/// Execute all tasks on the current-thread. CurrentThread(CurrentThread), /// Execute tasks across multiple threads. #[cfg(feature = "rt-multi-thread")] MultiThread(MultiThread), } impl Runtime { pub(super) fn from_parts( scheduler: Scheduler, handle: Handle, blocking_pool...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c03a37fa0b88ec20df22bec2b035852fd1eab44e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c03a37fa0b88ec20df22bec2b035852fd1eab44e/tokio/src/runtime/runtime.rs
121
180
tokio-rs/tokio:tokio/src/runtime/runtime.rs:6
} /// Spawns a future onto the Tokio runtime. /// /// This spawns the given future onto the runtime's executor, usually a /// thread pool. The thread pool is then responsible for polling the future /// until it completes. /// /// The provided future will start running in the background imme...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c03a37fa0b88ec20df22bec2b035852fd1eab44e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c03a37fa0b88ec20df22bec2b035852fd1eab44e/tokio/src/runtime/runtime.rs
201
260
tokio-rs/tokio:tokio/src/runtime/runtime.rs:7
let fut_size = mem::size_of::<F>(); if fut_size > BOX_FUTURE_THRESHOLD { self.handle .spawn_named(Box::pin(future), SpawnMeta::new_unnamed(fut_size)) } else { self.handle .spawn_named(future, SpawnMeta::new_unnamed(fut_size)) } } /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c03a37fa0b88ec20df22bec2b035852fd1eab44e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c03a37fa0b88ec20df22bec2b035852fd1eab44e/tokio/src/runtime/runtime.rs
241
300
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9
/// # #[cfg(not(target_family = "wasm"))] /// # { /// use tokio::runtime::Runtime; /// /// // Create the runtime /// let rt = Runtime::new().unwrap(); /// /// // Execute the future, blocking the current thread until completion /// rt.block_on(async { /// println!("hello"); /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c03a37fa0b88ec20df22bec2b035852fd1eab44e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c03a37fa0b88ec20df22bec2b035852fd1eab44e/tokio/src/runtime/runtime.rs
321
380
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12
/// /// runtime.shutdown_timeout(Duration::from_millis(100)); /// } /// # } /// ``` pub fn shutdown_timeout(mut self, duration: Duration) { // Wakeup and shutdown all the worker threads self.handle.inner.shutdown(); self.blocking_pool.shutdown(Some(duration)); } /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c03a37fa0b88ec20df22bec2b035852fd1eab44e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c03a37fa0b88ec20df22bec2b035852fd1eab44e/tokio/src/runtime/runtime.rs
441
500
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13
/// # } /// ``` pub fn shutdown_background(self) { self.shutdown_timeout(Duration::from_nanos(0)); } /// Returns a view that lets you get information about how the runtime /// is performing. pub fn metrics(&self) -> crate::runtime::RuntimeMetrics { self.handle.metrics() } } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
c03a37fa0b88ec20df22bec2b035852fd1eab44e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c03a37fa0b88ec20df22bec2b035852fd1eab44e/tokio/src/runtime/runtime.rs
481
515
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12
/// }); /// /// runtime.shutdown_timeout(Duration::from_millis(100)); /// } /// # } /// ``` pub fn shutdown_timeout(mut self, duration: Duration) { // Wakeup and shutdown all the worker threads self.handle.inner.shutdown(); self.blocking_pool.shutdown(Some(duration)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
d1f1499f630c34c1d319acdc2cc86d7a1008c4b4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/runtime.rs
441
500
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13
/// } /// # } /// ``` pub fn shutdown_background(self) { self.shutdown_timeout(Duration::from_nanos(0)); } /// Returns a view that lets you get information about how the runtime /// is performing. pub fn metrics(&self) -> crate::runtime::RuntimeMetrics { self.handle.metrics(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
d1f1499f630c34c1d319acdc2cc86d7a1008c4b4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/runtime.rs
481
516
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9
/// # #[cfg(not(target_family = "wasm"))] /// # { /// use tokio::runtime::Runtime; /// /// // Create the runtime /// let rt = Runtime::new().unwrap(); /// /// // Execute the future, blocking the current thread until completion /// rt.block_on(async { /// println!("hello"); /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/runtime/runtime.rs
321
380
tokio-rs/tokio:tokio/src/runtime/runtime.rs:6
/// /// This spawns the given future onto the runtime's executor, usually a /// thread pool. The thread pool is then responsible for polling the future /// until it completes. /// /// The provided future will start running in the background immediately /// when `spawn` is called, even if you don...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
9563707aaa73a802fa4d3c51c12869a037641070
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9563707aaa73a802fa4d3c51c12869a037641070/tokio/src/runtime/runtime.rs
201
260
tokio-rs/tokio:tokio/src/runtime/runtime.rs:8
/// worker. The expectation is that other tasks are spawned by the future here. /// Awaiting on other futures from the future provided here will not /// perform as fast as those spawned as workers. /// /// # Multi thread scheduler /// /// When the multi thread scheduler is used this will allow f...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
9563707aaa73a802fa4d3c51c12869a037641070
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9563707aaa73a802fa4d3c51c12869a037641070/tokio/src/runtime/runtime.rs
281
340
tokio-rs/tokio:tokio/src/runtime/runtime.rs:9
/// ``` /// /// [handle]: fn@Handle::block_on #[track_caller] pub fn block_on<F: Future>(&self, future: F) -> F::Output { let fut_size = mem::size_of::<F>(); if fut_size > BOX_FUTURE_THRESHOLD { self.block_on_inner(Box::pin(future), SpawnMeta::new_unnamed(fut_size)) }...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
9563707aaa73a802fa4d3c51c12869a037641070
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9563707aaa73a802fa4d3c51c12869a037641070/tokio/src/runtime/runtime.rs
321
380
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12
/// /// Note however, that because we do not wait for any blocking tasks to complete, this /// may result in a resource leak (in that any blocking tasks are still running until they /// return. /// /// See the [struct level documentation](Runtime#shutdown) for more details. /// /// This func...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
9563707aaa73a802fa4d3c51c12869a037641070
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9563707aaa73a802fa4d3c51c12869a037641070/tokio/src/runtime/runtime.rs
441
495
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13
current_thread.shutdown(&self.handle.inner); } #[cfg(feature = "rt-multi-thread")] Scheduler::MultiThread(multi_thread) => { // The threaded scheduler drops its tasks on its worker threads, which is // already in the runtime's context. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
9563707aaa73a802fa4d3c51c12869a037641070
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9563707aaa73a802fa4d3c51c12869a037641070/tokio/src/runtime/runtime.rs
481
495
tokio-rs/tokio:tokio/src/runtime/runtime.rs:12
/// /// Note however, that because we do not wait for any blocking tasks to complete, this /// may result in a resource leak (in that any blocking tasks are still running until they /// return. /// /// See the [struct level documentation](Runtime#shutdown) for more details. /// /// This func...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
1ea9ce11d4317d767136d489041548408348be77
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1ea9ce11d4317d767136d489041548408348be77/tokio/src/runtime/runtime.rs
441
496
tokio-rs/tokio:tokio/src/runtime/runtime.rs:13
let _guard = context::try_set_current(&self.handle.inner); current_thread.shutdown(&self.handle.inner); } #[cfg(feature = "rt-multi-thread")] Scheduler::MultiThread(multi_thread) => { // The threaded scheduler drops its tasks on its worker threads, whi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/runtime.rs
MIT
1ea9ce11d4317d767136d489041548408348be77
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1ea9ce11d4317d767136d489041548408348be77/tokio/src/runtime/runtime.rs
481
496