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/io/scheduled_io.rs:15 | // still didn't return `Poll::Ready`.
let tick = TICK.unpack(curr) as u8;
// The readiness state could have been cleared in the meantime,
// but we allow the returned ready set to be empty.
let curr_ready = Ready::from_usize(READINESS.unpa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/io/scheduled_io.rs | 561 | 594 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | Done,
}
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | driver tick | readiness |
// |----------+-------------+-----------|
// | 1 bit | 8 bits + 16 bits |
const READINESS: bit::Pack = bit::Pack::least_significant(16);
const TICK: bit::Pack = READINESS.then(8)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 0f296d2089ccbe9861ad78792326d393d1db1a48 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0f296d2089ccbe9861ad78792326d393d1db1a48/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | Done,
}
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | driver tick | readiness |
// |----------+-------------+-----------|
// | 1 bit | 8 bits + 16 bits |
const READINESS: bit::Pack = bit::Pack::least_significant(16);
const TICK: bit::Pack = READINESS.then(8)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 1c428cc558bd3be71fcd9466010b2ff0ed4048b6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1c428cc558bd3be71fcd9466010b2ff0ed4048b6/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:6 | /// Sets the readiness on this `ScheduledIo` by invoking the given closure on
/// the current value, returning the previous readiness value.
///
/// # Arguments
/// - `tick`: whether setting the tick or trying to clear readiness for a
/// specific tick.
/// - `f`: a closure returning a new re... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 1c428cc558bd3be71fcd9466010b2ff0ed4048b6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1c428cc558bd3be71fcd9466010b2ff0ed4048b6/tokio/src/runtime/io/scheduled_io.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:1 | use crate::io::interest::Interest;
use crate::io::ready::Ready;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Mutex;
use crate::runtime::io::{Direction, ReadyEvent, Tick};
use crate::util::bit;
use crate::util::linked_list::{self, LinkedList};
use crate::util::WakeList;
use std::cell::UnsafeCell;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:2 | target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "powerpc64",
),
repr(align(128))
)]
// arm, mips, mips64, riscv64, sparc, and hexagon have 32-byte cache line size.
//
// Sources:
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:3 | #[cfg_attr(target_arch = "s390x", repr(align(256)))]
// x86, wasm, and sparc64 have 64-byte cache line size.
//
// Sources:
// - https://github.com/golang/go/blob/dda2991c2ea0c5914714469c4defc2562a907230/src/internal/cpu/cpu_x86.go#L9
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:4 | list: WaitList,
/// Waker used for AsyncRead.
reader: Option<Waker>,
/// Waker used for AsyncWrite.
writer: Option<Waker>,
}
#[derive(Debug)]
struct Waiter {
pointers: linked_list::Pointers<Waiter>,
/// The waker for this task.
waker: Option<Waker>,
/// The interest this waiter is w... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | waiter: UnsafeCell<Waiter>,
}
enum State {
Init,
Waiting,
Done,
}
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | driver tick | readiness |
// |----------+-------------+-----------|
// | 1 bit | 8 bits + 16 bits |
const READINESS: bit::Pack = bit::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:6 | /// permanently shutdown state.
pub(super) fn shutdown(&self) {
let mask = SHUTDOWN.pack(1, 0);
self.readiness.fetch_or(mask, AcqRel);
self.wake(Ready::ALL);
}
/// Sets the readiness on this `ScheduledIo` by invoking the given closure on
/// the current value, returning the prev... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:7 | .readiness
.compare_exchange(current, next, AcqRel, Acquire)
{
Ok(_) => return,
// we lost the race, retry!
Err(actual) => current = actual,
}
}
}
/// Notifies all pending waiters that have registered interest in `r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:8 | let mut iter = waiters.list.drain_filter(|w| ready.satisfies(w.interest));
while wakers.can_push() {
match iter.next() {
Some(waiter) => {
let waiter = unsafe { &mut *waiter.as_ptr() };
if let Some(waker) = waiter.waker.ta... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:9 | }
/// Polls for readiness events in a given direction.
///
/// These are to support `AsyncRead` and `AsyncWrite` polling methods,
/// which cannot use the `async fn` version. This uses reserved reader
/// and writer slots.
pub(super) fn poll_readiness(
&self,
cx: &mut Context<'_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:10 | let curr = self.readiness.load(Acquire);
let ready = direction.mask() & Ready::from_usize(READINESS.unpack(curr));
let is_shutdown = SHUTDOWN.unpack(curr) != 0;
if is_shutdown {
Poll::Ready(ReadyEvent {
tick: TICK.unpack(curr) as u8,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:11 | impl Drop for ScheduledIo {
fn drop(&mut self) {
self.wake(Ready::ALL);
}
}
unsafe impl Send for ScheduledIo {}
unsafe impl Sync for ScheduledIo {}
impl ScheduledIo {
/// An async version of `poll_readiness` which uses a linked list of wakers.
pub(crate) async fn readiness(&self, interest: Int... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:12 | *handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr
}
unsafe fn pointers(target: NonNull<Waiter>) -> NonNull<linked_list::Pointers<Waiter>> {
Waiter::addr_of_pointers(target)
}
}
// ===== impl Readiness =====
impl Future for Readiness<'_> {
type Output... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:13 | *state = State::Done;
return Poll::Ready(ReadyEvent {
tick,
ready,
is_shutdown,
});
}
// Wasn't ready, take the lock (and check again while locked)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:14 | //
// safety: pointers from `UnsafeCell` are never null.
waiters
.list
.push_front(unsafe { NonNull::new_unchecked(waiter.get()) });
*state = State::Waiting;
}
State::Waiting => {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:15 | let curr = scheduled_io.readiness.load(Acquire);
let is_shutdown = SHUTDOWN.unpack(curr) != 0;
// The returned tick might be newer than the event
// which notified our waker. This is ok because the future
// still didn't return `Poll::Read... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 6e42c26c803e39ea92251487ddd50322b170c52d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6e42c26c803e39ea92251487ddd50322b170c52d/tokio/src/runtime/io/scheduled_io.rs | 561 | 600 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:1 | use crate::io::interest::Interest;
use crate::io::ready::Ready;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Mutex;
use crate::runtime::io::{Direction, ReadyEvent, Tick};
use crate::util::bit;
use crate::util::linked_list::{self, LinkedList};
use crate::util::WakeList;
use std::cell::UnsafeCell;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:2 | }
#[derive(Debug)]
struct Waiter {
pointers: linked_list::Pointers<Waiter>,
/// The waker for this task.
waker: Option<Waker>,
/// The interest this waiter is waiting on.
interest: Interest,
is_ready: bool,
/// Should never be `!Unpin`.
_p: PhantomPinned,
}
generate_addr_of_methods... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:3 | }
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | driver tick | readiness |
// |----------+-------------+-----------|
// | 1 bit | 8 bits + 16 bits |
const READINESS: bit::Pack = bit::Pack::least_significant(16);
const TICK: bit::Pack = READINESS.then(8);
con... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:4 | /// Sets the readiness on this `ScheduledIo` by invoking the given closure on
/// the current value, returning the previous readiness value.
///
/// # Arguments
/// - `tick`: whether setting the tick or trying to clear readiness for a
/// specific tick.
/// - `f`: a closure returning a new re... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | }
}
/// Notifies all pending waiters that have registered interest in `ready`.
///
/// There may be many waiters to notify. Waking the pending task **must** be
/// done from outside of the lock otherwise there is a potential for a
/// deadlock.
///
/// A stack array of wakers is created... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:6 | if let Some(waker) = waiter.waker.take() {
waiter.is_ready = true;
wakers.push(waker);
}
}
None => {
break 'outer;
}
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:7 | pub(super) fn poll_readiness(
&self,
cx: &mut Context<'_>,
direction: Direction,
) -> Poll<ReadyEvent> {
let curr = self.readiness.load(Acquire);
let ready = direction.mask() & Ready::from_usize(READINESS.unpack(curr));
let is_shutdown = SHUTDOWN.unpack(curr) != 0;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:8 | is_shutdown,
})
} else if ready.is_empty() {
Poll::Pending
} else {
Poll::Ready(ReadyEvent {
tick: TICK.unpack(curr) as u8,
ready,
is_shutdown,
})
}
} e... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:9 | unsafe impl Send for ScheduledIo {}
unsafe impl Sync for ScheduledIo {}
impl ScheduledIo {
/// An async version of `poll_readiness` which uses a linked list of wakers.
pub(crate) async fn readiness(&self, interest: Interest) -> ReadyEvent {
self.readiness_fut(interest).await
}
// This is in a ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:10 | unsafe fn pointers(target: NonNull<Waiter>) -> NonNull<linked_list::Pointers<Waiter>> {
Waiter::addr_of_pointers(target)
}
}
// ===== impl Readiness =====
impl Future for Readiness<'_> {
type Output = ReadyEvent;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:11 | // Wasn't ready, take the lock (and check again while locked).
let mut waiters = scheduled_io.waiters.lock();
let curr = scheduled_io.readiness.load(SeqCst);
let mut ready = Ready::from_usize(READINESS.unpack(curr));
let is_shutdown = SHUT... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:12 | State::Waiting => {
// Currently in the "Waiting" state, implying the caller has
// a waiter stored in the waiter list (guarded by
// `notify.waiters`). In order to access the waker fields,
// we must hold the lock.
let... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:13 | let tick = TICK.unpack(curr) as u8;
// The readiness state could have been cleared in the meantime,
// but we allow the returned ready set to be empty.
let curr_ready = Ready::from_usize(READINESS.unpack(curr));
let ready = curr_ready.inte... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | b573adc733dc4cbff7b125738e2708e2518cca16 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b573adc733dc4cbff7b125738e2708e2518cca16/tokio/src/runtime/io/scheduled_io.rs | 481 | 513 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:1 | use crate::io::interest::Interest;
use crate::io::ready::Ready;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Mutex;
use crate::runtime::io::{Direction, ReadyEvent, Tick};
use crate::util::bit;
use crate::util::linked_list::{self, LinkedList};
use crate::util::slab::Entry;
use crate::util::WakeList... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:2 | #[derive(Debug)]
struct Waiter {
pointers: linked_list::Pointers<Waiter>,
/// The waker for this task.
waker: Option<Waker>,
/// The interest this waiter is waiting on.
interest: Interest,
is_ready: bool,
/// Should never be `!Unpin`.
_p: PhantomPinned,
}
generate_addr_of_methods! {... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:3 | // The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | generation | driver tick | readiness |
// |----------+------------+--------------+-----------|
// | 1 bit | 7 bits + 8 bits + 16 bits |
const READINESS: bit::Pack = bit::Pack::least_significant(16);
const TI... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:4 | }
impl ScheduledIo {
pub(crate) fn generation(&self) -> usize {
GENERATION.unpack(self.readiness.load(Acquire))
}
/// Invoked when the IO driver is shut down; forces this ScheduledIo into a
/// permanently shutdown state.
pub(super) fn shutdown(&self) {
let mask = SHUTDOWN.pack(1, ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | let current_generation = GENERATION.unpack(current);
if let Some(token) = token {
// Check that the generation for this access is still the
// current one.
if GENERATION.unpack(token) != current_generation {
return Err(());
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:6 | /// Notifies all pending waiters that have registered interest in `ready`.
///
/// There may be many waiters to notify. Waking the pending task **must** be
/// done from outside of the lock otherwise there is a potential for a
/// deadlock.
///
/// A stack array of wakers is created and filled w... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:7 | }
}
None => {
break 'outer;
}
}
}
drop(waiters);
wakers.wake_all();
// Acquire the lock again.
waiters = self.waiters.lock();
}
// Release t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:8 | direction: Direction,
) -> Poll<ReadyEvent> {
let curr = self.readiness.load(Acquire);
let ready = direction.mask() & Ready::from_usize(READINESS.unpack(curr));
let is_shutdown = SHUTDOWN.unpack(curr) != 0;
if ready.is_empty() && !is_shutdown {
// Update the task info
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:9 | Poll::Pending
} else {
Poll::Ready(ReadyEvent {
tick: TICK.unpack(curr) as u8,
ready,
is_shutdown,
})
}
} else {
Poll::Ready(ReadyEvent {
tick: TICK.unpack(curr) as u8,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:10 | unsafe impl Sync for ScheduledIo {}
impl ScheduledIo {
/// An async version of `poll_readiness` which uses a linked list of wakers.
pub(crate) async fn readiness(&self, interest: Interest) -> ReadyEvent {
self.readiness_fut(interest).await
}
// This is in a separate function so that the borrow... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:11 | Waiter::addr_of_pointers(target)
}
}
// ===== impl Readiness =====
impl Future for Readiness<'_> {
type Output = ReadyEvent;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
use std::sync::atomic::Ordering::SeqCst;
let (scheduled_io, state, waiter) = unsafe {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:12 | // Wasn't ready, take the lock (and check again while locked).
let mut waiters = scheduled_io.waiters.lock();
let curr = scheduled_io.readiness.load(SeqCst);
let mut ready = Ready::from_usize(READINESS.unpack(curr));
let is_shutdown = SHUT... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:13 | // Currently in the "Waiting" state, implying the caller has
// a waiter stored in the waiter list (guarded by
// `notify.waiters`). In order to access the waker fields,
// we must hold the lock.
let waiters = scheduled_io.waiters.lock();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:14 | // The readiness state could have been cleared in the meantime,
// but we allow the returned ready set to be empty.
let curr_ready = Ready::from_usize(READINESS.unpack(curr));
let ready = curr_ready.intersection(w.interest);
return Poll::R... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | ce23db6bc7c6a2853377db629ca8b761a45e0476 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ce23db6bc7c6a2853377db629ca8b761a45e0476/tokio/src/runtime/io/scheduled_io.rs | 521 | 552 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:1 | use super::{ReadyEvent, Tick};
use crate::io::interest::Interest;
use crate::io::ready::Ready;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Mutex;
use crate::util::bit;
use crate::util::slab::Entry;
use crate::util::WakeList;
use std::sync::atomic::Ordering::{AcqRel, Acquire, Release};
use std::t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:2 | /// List of all current waiters.
list: WaitList,
/// Waker used for AsyncRead.
reader: Option<Waker>,
/// Waker used for AsyncWrite.
writer: Option<Waker>,
}
cfg_io_readiness! {
#[derive(Debug)]
struct Waiter {
pointers: linked_list::Pointers<Waiter>,
/// The waker for th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:3 | /// Entry in the waiter `LinkedList`.
waiter: UnsafeCell<Waiter>,
}
enum State {
Init,
Waiting,
Done,
}
}
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | shutdown | generation | driver tick | readiness |
// |----------+------------+-----... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:4 | self.readiness.store(next, Release);
}
}
impl Default for ScheduledIo {
fn default() -> ScheduledIo {
ScheduledIo {
readiness: AtomicUsize::new(0),
waiters: Mutex::new(Default::default()),
}
}
}
impl ScheduledIo {
pub(crate) fn generation(&self) -> usize {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | /// replaced with a new resource. In that case, this method returns `Err`.
/// Otherwise, this returns the previous readiness.
pub(super) fn set_readiness(
&self,
token: Option<usize>,
tick: Tick,
f: impl Fn(Ready) -> Ready,
) -> Result<(), ()> {
let mut current = sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:6 | match self
.readiness
.compare_exchange(current, next, AcqRel, Acquire)
{
Ok(_) => return Ok(()),
// we lost the race, retry!
Err(actual) => current = actual,
}
}
}
/// Notifies all pending waiters t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:7 | #[cfg(feature = "net")]
'outer: loop {
let mut iter = waiters.list.drain_filter(|w| ready.satisfies(w.interest));
while wakers.can_push() {
match iter.next() {
Some(waiter) => {
let waiter = unsafe { &mut *waiter.as_ptr() };
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:8 | is_shutdown: SHUTDOWN.unpack(curr) != 0,
}
}
/// Polls for readiness events in a given direction.
///
/// These are to support `AsyncRead` and `AsyncWrite` polling methods,
/// which cannot use the `async fn` version. This uses reserved reader
/// and writer slots.
pub(super) fn pol... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:9 | // Try again, in case the readiness was changed while we were
// taking the waiters lock
let curr = self.readiness.load(Acquire);
let ready = direction.mask() & Ready::from_usize(READINESS.unpack(curr));
let is_shutdown = SHUTDOWN.unpack(curr) != 0;
if is_shut... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:10 | waiters.reader.take();
waiters.writer.take();
}
}
impl Drop for ScheduledIo {
fn drop(&mut self) {
self.wake(Ready::ALL);
}
}
unsafe impl Send for ScheduledIo {}
unsafe impl Sync for ScheduledIo {}
cfg_io_readiness! {
impl ScheduledIo {
/// An async version of `poll_readiness`... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:11 | unsafe impl linked_list::Link for Waiter {
type Handle = NonNull<Waiter>;
type Target = Waiter;
fn as_raw(handle: &NonNull<Waiter>) -> NonNull<Waiter> {
*handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr
}
unsafe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:12 | let ready = ready.intersection(interest);
if !ready.is_empty() || is_shutdown {
// Currently ready!
let tick = TICK.unpack(curr) as u8;
*state = State::Done;
return Poll::Ready(ReadyE... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:14 | // The returned tick might be newer than the event
// which notified our waker. This is ok because the future
// still didn't return `Poll::Ready`.
let tick = TICK.unpack(curr) as u8;
// The readiness state could have been ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 9af2f5ee5931a79684d4afd8897e54aafa39c156 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9af2f5ee5931a79684d4afd8897e54aafa39c156/tokio/src/runtime/io/scheduled_io.rs | 521 | 558 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:1 | use super::{ReadyEvent, Tick};
use crate::io::interest::Interest;
use crate::io::ready::Ready;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Mutex;
use crate::util::bit;
use crate::util::slab::Entry;
use crate::util::WakeList;
use std::sync::atomic::Ordering::{AcqRel, Acquire, Release};
use std::t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:2 | /// List of all current waiters.
list: WaitList,
/// Waker used for AsyncRead.
reader: Option<Waker>,
/// Waker used for AsyncWrite.
writer: Option<Waker>,
/// True if this ScheduledIo has been killed due to IO driver shutdown.
is_shutdown: bool,
}
cfg_io_readiness! {
#[derive(Debug)... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:3 | scheduled_io: &'a ScheduledIo,
state: State,
/// Entry in the waiter `LinkedList`.
waiter: UnsafeCell<Waiter>,
}
enum State {
Init,
Waiting,
Done,
}
}
// The `ScheduledIo::readiness` (`AtomicUsize`) is packed full of goodness.
//
// | reserved | generation... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:4 | self.readiness.store(next, Release);
}
}
impl Default for ScheduledIo {
fn default() -> ScheduledIo {
ScheduledIo {
readiness: AtomicUsize::new(0),
waiters: Mutex::new(Default::default()),
}
}
}
impl ScheduledIo {
pub(crate) fn generation(&self) -> usize {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:5 | /// Otherwise, this returns the previous readiness.
pub(super) fn set_readiness(
&self,
token: Option<usize>,
tick: Tick,
f: impl Fn(Ready) -> Ready,
) -> Result<(), ()> {
let mut current = self.readiness.load(Acquire);
loop {
let current_generation =... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:6 | .readiness
.compare_exchange(current, next, AcqRel, Acquire)
{
Ok(_) => return Ok(()),
// we lost the race, retry!
Err(actual) => current = actual,
}
}
}
/// Notifies all pending waiters that have registered interes... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:7 | if let Some(waker) = waiters.writer.take() {
wakers.push(waker);
}
}
#[cfg(feature = "net")]
'outer: loop {
let mut iter = waiters.list.drain_filter(|w| ready.satisfies(w.interest));
while wakers.can_push() {
match iter.next()... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:8 | let curr = self.readiness.load(Acquire);
ReadyEvent {
tick: TICK.unpack(curr) as u8,
ready: interest.mask() & Ready::from_usize(READINESS.unpack(curr)),
}
}
/// Polls for readiness events in a given direction.
///
/// These are to support `AsyncRead` and `AsyncW... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:9 | }
}
// Try again, in case the readiness was changed while we were
// taking the waiters lock
let curr = self.readiness.load(Acquire);
let ready = direction.mask() & Ready::from_usize(READINESS.unpack(curr));
if waiters.is_shutdown {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:10 | waiters.writer.take();
}
}
impl Drop for ScheduledIo {
fn drop(&mut self) {
self.wake(Ready::ALL);
}
}
unsafe impl Send for ScheduledIo {}
unsafe impl Sync for ScheduledIo {}
cfg_io_readiness! {
impl ScheduledIo {
/// An async version of `poll_readiness` which uses a linked list of wa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:11 | type Handle = NonNull<Waiter>;
type Target = Waiter;
fn as_raw(handle: &NonNull<Waiter>) -> NonNull<Waiter> {
*handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr
}
unsafe fn pointers(target: NonNull<Waiter>) -> NonNull<li... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:12 | if !ready.is_empty() {
// Currently ready!
let tick = TICK.unpack(curr) as u8;
*state = State::Done;
return Poll::Ready(ReadyEvent { tick, ready });
}
// Wasn'... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:13 | }
State::Waiting => {
// Currently in the "Waiting" state, implying the caller has
// a waiter stored in the waiter list (guarded by
// `notify.waiters`). In order to access the waker fields,
// we must h... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/io/scheduled_io.rs:14 | let tick = TICK.unpack(curr) as u8;
// The readiness state could have been cleared in the meantime,
// but we allow the returned ready set to be empty.
let curr_ready = Ready::from_usize(READINESS.unpack(curr));
let ready =... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/io/scheduled_io.rs | MIT | 644cb8207df09c19543cf9b096a43a66f8df9a0f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/644cb8207df09c19543cf9b096a43a66f8df9a0f/tokio/src/runtime/io/scheduled_io.rs | 521 | 553 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/mod.rs:1 | mod runtime;
mod options;
pub use options::LocalOptions;
pub use runtime::LocalRuntime;
pub(super) use runtime::LocalRuntimeScheduler; | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/local_runtime/mod.rs | 1 | 7 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/options.rs:1 | use std::marker::PhantomData;
/// [`LocalRuntime`]-only config options
///
/// Currently, there are no such options, but in the future, things like `!Send + !Sync` hooks may
/// be added.
///
/// Use `LocalOptions::default()` to create the default set of options. This type is used with
/// [`Builder::build_local`].
//... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/options.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/local_runtime/options.rs | 1 | 18 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/options.rs:1 | use std::marker::PhantomData;
/// `LocalRuntime`-only config options
///
/// Currently, there are no such options, but in the future, things like `!Send + !Sync` hooks may
/// be added.
#[derive(Default, Debug)]
#[non_exhaustive]
pub struct LocalOptions {
/// Marker used to make this !Send and !Sync.
_phantom:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/options.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/local_runtime/options.rs | 1 | 12 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:1 | #![allow(irrefutable_let_patterns)]
use crate::runtime::blocking::BlockingPool;
use crate::runtime::scheduler::CurrentThread;
use crate::runtime::{context, Builder, EnterGuard, Handle, BOX_FUTURE_THRESHOLD};
use crate::task::JoinHandle;
use crate::util::trace::SpawnMeta;
use std::future::Future;
use std::marker::Phan... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/local_runtime/runtime.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:2 | /// Marker used to make this !Send and !Sync.
_phantom: PhantomData<*mut u8>,
}
/// The runtime scheduler is always a `current_thread` scheduler right now.
#[derive(Debug)]
pub(crate) enum LocalRuntimeScheduler {
/// Execute all tasks on the current-thread.
CurrentThread(CurrentThread),
}
impl LocalRuntim... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/local_runtime/runtime.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:4 | }
/// Spawns a task on the runtime.
///
/// This is analogous to the [`spawn`] method on the standard [`Runtime`], but works even if the task is not thread-safe.
///
/// [`spawn`]: crate::runtime::Runtime::spawn
/// [`Runtime`]: crate::runtime::Runtime
///
/// # Examples
///
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/local_runtime/runtime.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:6 | /// for more information.
///
/// [Runtime]: crate::runtime::Runtime::block_on
///
/// # Examples
///
/// ```no_run
/// use tokio::runtime::LocalRuntime;
///
/// // Create the runtime
/// let rt = LocalRuntime::new().unwrap();
///
/// // Execute the future, blocking the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/local_runtime/runtime.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:7 | #[cfg(all(tokio_unstable, feature = "tracing"))]
let future = crate::util::trace::task(
future,
"block_on",
_meta,
crate::runtime::task::Id::next().as_u64(),
);
let _enter = self.enter();
if let LocalRuntimeScheduler::CurrentThread(exec) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/local_runtime/runtime.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:10 | /// let runtime = LocalRuntime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = LocalRuntime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
/// });
/// }
/// ```
pub fn shutdown_background(self) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/local_runtime/runtime.rs | 361 | 396 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:1 | #![allow(irrefutable_let_patterns)]
use crate::runtime::blocking::BlockingPool;
use crate::runtime::scheduler::CurrentThread;
use crate::runtime::{context, Builder, EnterGuard, Handle, BOX_FUTURE_THRESHOLD};
use crate::task::JoinHandle;
use crate::util::trace::SpawnMeta;
use std::future::Future;
use std::marker::Phan... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/local_runtime/runtime.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:2 | blocking_pool: BlockingPool,
/// Marker used to make this !Send and !Sync.
_phantom: PhantomData<*mut u8>,
}
/// The runtime scheduler is always a `current_thread` scheduler right now.
#[derive(Debug)]
pub(crate) enum LocalRuntimeScheduler {
/// Execute all tasks on the current-thread.
CurrentThread(C... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/local_runtime/runtime.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:4 | &self.handle
}
/// Spawns a task on the runtime.
///
/// This is analogous to the [`spawn`] method on the standard [`Runtime`], but works even if the task is not thread-safe.
///
/// [`spawn`]: crate::runtime::Runtime::spawn
/// [`Runtime`]: crate::runtime::Runtime
///
/// # Example... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/local_runtime/runtime.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:6 | /// See the documentation for [the equivalent method on Runtime][Runtime]
/// for more information.
///
/// [Runtime]: crate::runtime::Runtime::block_on
///
/// # Examples
///
/// ```no_run
/// use tokio::runtime::LocalRuntime;
///
/// // Create the runtime
/// let rt = Loca... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/local_runtime/runtime.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:7 | #[cfg(all(tokio_unstable, feature = "tracing"))]
let future = crate::util::trace::task(
future,
"block_on",
_meta,
crate::runtime::task::Id::next().as_u64(),
);
let _enter = self.enter();
if let LocalRuntimeScheduler::CurrentThread(exec) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/local_runtime/runtime.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:10 | /// fn main() {
/// let runtime = LocalRuntime::new().unwrap();
///
/// runtime.block_on(async move {
/// let inner_runtime = LocalRuntime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
/// });
/// }
/// ```
pub fn shutdown_back... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | d1f1499f630c34c1d319acdc2cc86d7a1008c4b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d1f1499f630c34c1d319acdc2cc86d7a1008c4b4/tokio/src/runtime/local_runtime/runtime.rs | 361 | 397 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:6 | /// See the documentation for [the equivalent method on Runtime][Runtime]
/// for more information.
///
/// [Runtime]: crate::runtime::Runtime::block_on
///
/// # Examples
///
/// ```no_run
/// use tokio::runtime::LocalRuntime;
///
/// // Create the runtime
/// let rt = Loca... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/runtime/local_runtime/runtime.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:10 | /// runtime.block_on(async move {
/// let inner_runtime = LocalRuntime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
/// });
/// }
/// ```
pub fn shutdown_background(self) {
self.shutdown_timeout(Duration::from_nanos(0));
}
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | 9563707aaa73a802fa4d3c51c12869a037641070 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9563707aaa73a802fa4d3c51c12869a037641070/tokio/src/runtime/local_runtime/runtime.rs | 361 | 394 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:10 | /// runtime.block_on(async move {
/// let inner_runtime = LocalRuntime::new().unwrap();
/// // ...
/// inner_runtime.shutdown_background();
/// });
/// }
/// ```
pub fn shutdown_background(self) {
self.shutdown_timeout(Duration::from_nanos(0));
}
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | 17d8c2b29d94550f504d8fd76d8d8aaf66095864 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/17d8c2b29d94550f504d8fd76d8d8aaf66095864/tokio/src/runtime/local_runtime/runtime.rs | 361 | 395 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:2 | blocking_pool: BlockingPool,
/// Marker used to make this !Send and !Sync.
_phantom: PhantomData<*mut u8>,
}
/// The runtime scheduler is always a `current_thread` scheduler right now.
#[derive(Debug)]
pub(crate) enum LocalRuntimeScheduler {
/// Execute all tasks on the current-thread.
CurrentThread(C... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | 15f73666f18e0853fe1f730bbe8b9b1618fb1016 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/15f73666f18e0853fe1f730bbe8b9b1618fb1016/tokio/src/runtime/local_runtime/runtime.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:4 | &self.handle
}
/// Spawns a task on the runtime.
///
/// This is analogous to the [`spawn`] method on the standard [`Runtime`], but works even if the task is not thread-safe.
///
/// [`spawn`]: crate::runtime::Runtime::spawn
/// [`Runtime`]: crate::runtime::Runtime
///
/// # Example... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/local_runtime/runtime.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:5 | }
}
}
/// Runs the provided function on a thread from a dedicated blocking thread pool.
///
/// This function _will_ be run on another thread.
///
/// See the documentation in the non-local runtime for more information.
///
/// [Runtime]: crate::runtime::Runtime::spawn_blocking
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/local_runtime/runtime.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:6 | ///
/// [Runtime]: crate::runtime::Runtime::block_on
///
/// # Examples
///
/// ```no_run
/// use tokio::runtime::LocalRuntime;
///
/// // Create the runtime
/// let rt = LocalRuntime::new().unwrap();
///
/// // Execute the future, blocking the current thread until completio... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/local_runtime/runtime.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:7 | let future = crate::util::trace::task(
future,
"block_on",
_meta,
crate::runtime::task::Id::next().as_u64(),
);
let _enter = self.enter();
if let LocalRuntimeScheduler::CurrentThread(exec) = &self.scheduler {
exec.block_on(&self.handl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/local_runtime/runtime.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:9 | /// let runtime = LocalRuntime::new().unwrap();
///
/// runtime.block_on(async move {
/// task::spawn_blocking(move || {
/// thread::sleep(Duration::from_secs(10_000));
/// });
/// });
///
/// runtime.shutdown_timeout(Duration::from_millis(100));
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/local_runtime/runtime.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/local_runtime/runtime.rs:10 | /// // ...
/// 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 me... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/local_runtime/runtime.rs | MIT | 512e9decfb683d22f4a145459142542caa0894c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/512e9decfb683d22f4a145459142542caa0894c9/tokio/src/runtime/local_runtime/runtime.rs | 361 | 393 |
tokio-rs/tokio:tokio/src/runtime/metrics/batch.rs:1 | use crate::runtime::metrics::WorkerMetrics;
cfg_unstable_metrics! {
use crate::runtime::metrics::HistogramBatch;
}
use std::sync::atomic::Ordering::Relaxed;
use std::time::{Duration, Instant};
pub(crate) struct MetricsBatch {
/// The total busy duration in nanoseconds.
busy_duration_total: u64,
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/metrics/batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/metrics/batch.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/metrics/batch.rs:2 | /// track the noop count.
poll_count_on_last_park: u64,
#[cfg(tokio_unstable)]
/// Number of tasks that were scheduled locally on this worker.
local_schedule_count: u64,
#[cfg(tokio_unstable)]
/// Number of tasks moved to the global queue to make space in the local
/// queue
overflow_c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/metrics/batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/metrics/batch.rs | 41 | 100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.