id
stringlengths
22
133
text
stringlengths
40
40.2k
arch
stringclasses
1 value
syntax
stringclasses
1 value
kind
stringclasses
4 values
repo
stringclasses
27 values
path
stringlengths
5
116
license
stringclasses
6 values
commit
stringlengths
40
40
source_host
stringclasses
1 value
category
stringclasses
16 values
source_url
stringlengths
85
196
line_start
int64
1
4.28k
line_end
int64
4
4.31k
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
// because we know that ob will set back to None before allow_blocking // is dropped. #[allow(clippy::useless_transmute)] std::mem::transmute::<_, *const dyn Fn()>(allow_blocking) })); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
/// Acquire the lock fn acquire_lock(&self) -> Option<GenerationGuard<'_, P>> { // Safety: Only getting `&self` access to access atomic field let owned = unsafe { &*self.slices.owned()[self.index].get() }; // The lock is only to establish mutual exclusion. Other synchronization // h...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
// separate (blocking) thread before returning. Once we return, the // caller is going to execute some blocking code which would otherwise // block our reactor from making progress. Since we are _in the middle_ // of running a task, this isn't trivial, as the Worker is "active". // We do...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
// Give away the worker self.blocking_pool.spawn_background(move || worker.run()); } } impl<P> GenerationGuard<'_, P> where P: Park + 'static, { fn run(self) -> Result<(), WorkerGone> { let mut me = self; while me.is_running() { me = me.process_available_work()?; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
// The scheduler is in the process of shutting down. return Ok(me); } // Break out of the local task loop and try to steal break; } }; me = me.run_task(task)?; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11
// Perform regularly scheduled maintenance work. self.maintenance(); if !self.is_running() { return None; } // Check the global queue self.owned().work_queue.pop_global_first() } else { self.owned().work_queue.pop_local_fi...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/runtime/thread_pool/worker.rs
401
460
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12
return true; } let ret = self.slices().idle().transition_worker_to_searching(); self.owned().is_searching.set(ret); ret } fn transition_from_searching(&mut self) { self.owned().is_searching.set(false); if self.slices().idle().transition_worker_from_searching() ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/runtime/thread_pool/worker.rs
441
500
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13
if self.owned().did_submit_task.get() || !self.is_running() { // Remove the worker from the sleep set. self.slices().idle().unpark_worker_by_id(self.index()); self.owned().is_searching.set(true); self.owned().defer_notification.set(false); true } els...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/runtime/thread_pool/worker.rs
481
540
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
// The Worker disappeared from under us. // We need to return, because we no longer own all of our state! // Make sure the task gets picked up again eventually. if let Some(task) = task { self.worker.slices.schedule(task); } Err(WorkerGone) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
if self.transition_from_parked() { return; } } } fn park_light(&mut self) { // When tasks are submitted locally (from the parker), defer any // notifications in hopes that the curent worker will grab those tasks. self.owned().defer_notification.set(tr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
self.owned().owned_tasks.shutdown(); // First, drain all tasks from both the local & global queue. while let Some(task) = self.owned().work_queue.pop_local_first() { task.shutdown(); } // Notify all workers in case they have pending tasks to drop // // Not s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
fn slices(&self) -> &slice::Set<P::Unpark> { &self.worker.slices } fn shared(&self) -> &Shared<P::Unpark> { &self.slices().shared()[self.index()] } fn owned(&self) -> &Owned<P::Unpark> { let index = self.index(); // safety: we own the slot unsafe { &*self.slices...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/runtime/thread_pool/worker.rs
641
661
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:1
use crate::blocking; use crate::loom::cell::CausalCell; use crate::loom::sync::Arc; use crate::runtime::park::{Park, Unpark}; use crate::runtime::thread_pool::{current, shutdown, slice, Callback, Owned, Shared, Spawner}; use crate::task::Task; use std::cell::Cell; use std::marker::PhantomData; use std::sync::atomic::O...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
1
60
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2
inner: Arc<Inner<P>>, /// Scheduler slices slices: Arc<slice::Set<P::Unpark>>, /// Slice assigned to this worker index: usize, /// Handle to the blocking pool blocking_pool: blocking::Spawner, /// Run before calling worker logic around_worker: Callback, /// Worker generation. Th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
41
100
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:3
/// Prevent `Sync` access _p: PhantomData<Cell<()>>, } struct WorkerGone; // TODO: Move into slices pub(super) fn create_set<F, P>( pool_size: usize, mk_park: F, blocking_pool: blocking::Spawner, around_worker: Callback, shutdown_tx: shutdown::Sender, ) -> (Arc<slice::Set<P::Unpark>>, Vec<Work...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
81
140
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4
}) .collect(); (slices, workers) } /// After how many ticks is the global queue polled. This helps to ensure /// fairness. /// /// The number is fairly arbitrary. I believe this value was copied from golang. const GLOBAL_POLL_INTERVAL: u16 = 61; impl<P> Worker<P> where P: Send + Park, { // Safe a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
121
180
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:5
pub(super) fn run(self) where P: Park<Unpark = Box<dyn Unpark>>, { (self.around_worker)(self.index, &mut || { // First, acquire a lock on the worker. let guard = match self.acquire_lock() { Some(guard) => guard, None => return, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
161
220
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
#[allow(clippy::useless_transmute)] std::mem::transmute::<_, *const dyn Fn()>(allow_blocking) })); let _ = guard.run(); // Ensure that we reset ob before allow_blocking is dropped. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
// Safety: Only getting `&self` access to access atomic field let owned = unsafe { &*self.slices.owned()[self.index].get() }; // The lock is only to establish mutual exclusion. Other synchronization // handles memory orderings let prev = owned.generation.compare_and_swap( se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
// block our reactor from making progress. Since we are _in the middle_ // of running a task, this isn't trivial, as the Worker is "active". // We do have the luxury of knowing that we are on the worker thread, // so we can assert exclusive access to any Worker-specific state. // ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
self.blocking_pool.spawn_background(move || worker.run()); } } impl<P> GenerationGuard<'_, P> where P: Park + 'static, { fn run(self) -> Result<(), WorkerGone> { let mut me = self; while me.is_running() { me = me.process_available_work()?; if me.is_running() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
} // Break out of the local task loop and try to steal break; } }; me = me.run_task(task)?; } // No more **local** work to process, try transitioning to searching // in order to att...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11
self.maintenance(); if !self.is_running() { return None; } // Check the global queue self.owned().work_queue.pop_global_first() } else { self.owned().work_queue.pop_local_first() } } fn steal_work(&mut self) -> Option...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
401
460
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12
let ret = self.slices().idle().transition_worker_to_searching(); self.owned().is_searching.set(ret); ret } fn transition_from_searching(&mut self) { self.owned().is_searching.set(false); if self.slices().idle().transition_worker_from_searching() { // We are the fina...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
441
500
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13
self.slices().idle().unpark_worker_by_id(self.index()); self.owned().is_searching.set(true); self.owned().defer_notification.set(false); true } else { let ret = !self.slices().idle().is_parked(self.index()); if ret { self.owned().is_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
481
540
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
// Make sure the task gets picked up again eventually. if let Some(task) = task { self.worker.slices.schedule(task); } Err(WorkerGone) } else { if let Some(task) = task { self.owned().submit_local_yield(task); self....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
} } } fn park_light(&mut self) { // When tasks are submitted locally (from the parker), defer any // notifications in hopes that the curent worker will grab those tasks. self.owned().defer_notification.set(true); self.park_mut() .park_timeout(Duration::from_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
// First, drain all tasks from both the local & global queue. while let Some(task) = self.owned().work_queue.pop_local_first() { task.shutdown(); } // Notify all workers in case they have pending tasks to drop // // Not super efficient, but we are also shutting down....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
601
659
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
&self.worker.slices } fn shared(&self) -> &Shared<P::Unpark> { &self.slices().shared()[self.index()] } fn owned(&self) -> &Owned<P::Unpark> { let index = self.index(); // safety: we own the slot unsafe { &*self.slices().owned()[index].get() } } fn park_mut(&mut...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/worker.rs
641
659
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:1
use crate::loom::sync::Arc; use crate::runtime::park::{Park, Unpark}; use crate::runtime::task::Task; use crate::runtime::thread_pool::{current, Owned, Shared, Spawner}; use std::cell::Cell; use std::ops::{Deref, DerefMut}; use std::time::Duration; // The Arc<Box<_>> is needed because loom doesn't support Arc<T> wher...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
1
60
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:2
pub(super) use crate::runtime::thread_pool::set::Set; pub(crate) struct Worker<P: Park + 'static> { /// Entry in the set of workers. entry: Entry<P::Unpark>, /// Park the thread park: Box<P>, /// Fn for launching another Worker should we need it launch_worker: LaunchWorker<P>, /// To ind...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
41
100
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:3
// unsafe is safe because we call Worker::new only once with each index in the pool unsafe { Worker::new(pool.clone(), index, park, Arc::clone(&launch_worker)) } }) .collect(); (pool, workers) } /// After how many ticks is the global queue polled. This helps to ensure /// fairness. ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
81
140
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4
let executor = &**pool; let spawner = Spawner::new(pool.clone()); let entry = &mut self.entry; let launch_worker = &self.launch_worker; let blocking = &executor.blocking; let gone = &self.gone; let mut park = DropNotGone::new(self.park, gone); // Track the curr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
121
180
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
// the task's execution won't assume that it owns a worker any // more. When the task yields, entry will use its `Arc<Set>` // (which is fine and safe), and then immediately return, // without calling any code th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
// is dropped. #[allow(clippy::useless_transmute)] std::mem::transmute::<_, *mut dyn FnMut()>(allow_blocking) })); let _ = entry.run(&mut **park, gone); // Ensure that we reset ob before all...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
} #[cfg(test)] #[allow(warnings)] pub(crate) fn tick(&mut self) { self.entry.tick(&mut *self.park, &self.gone); } } struct WorkerGone; struct Entry<P: 'static> { pool: Arc<Set<P>>, index: usize, } impl<P> Entry<P> where P: Unpark, { // unsafe because Entry::owned assumes ther...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
fn is_running(&mut self) -> bool { self.owned().is_running.get() } /// Returns `true` if the worker needs to park fn tick( &mut self, park: &mut impl Park<Unpark = P>, gone: &Cell<bool>, ) -> Result<bool, WorkerGone> { // Process all pending tasks in the local qu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
let tick = self.tick_fetch_inc(); let task = if tick % GLOBAL_POLL_INTERVAL == 0 { // Sleep light... self.park_light(park); // Perform regularly scheduled maintenance work. self.maintenance(); if !self.is_running() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11
/// state. fn maintenance(&mut self) { // Free any completed tasks self.drain_tasks_pending_drop(); // Update the pool state cache let closed = self.owned().work_queue.is_closed(); self.owned().is_running.set(!closed) } fn search_for_work(&mut self, gone: &Cell<bool...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
401
460
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12
/// Returns `true` if the worker must check for any work. fn transition_to_parked(&mut self) -> bool { let idx = self.index; let is_searching = self.is_searching(); let ret = self .set() .idle() .transition_worker_to_parked(idx, is_searching); // ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
441
500
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13
} } fn run_task(&mut self, task: Task<Shared<P>>, gone: &Cell<bool>) -> Result<(), WorkerGone> { if self.is_searching() { self.transition_from_searching(); } let executor = self.shared(); let task = task.run(&mut || { if gone.get() { None...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
481
540
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
if self.transition_to_parked() { // We are the final searching worker, check if any work arrived // before parking self.final_work_sweep(); } // The state has been transitioned to parked, we can now wait by // calling the parker. This is done in a loop as spu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
unsafe { let owned = &mut *self.set().owned()[self.index].get(); owned.release_task(&task); } drop(task); } } /// Shutdown the worker. /// /// Once the shutdown flag has been observed, it is guaranteed that no /// further tasks may be ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
/// Increment the tick, returning the value from before the increment. fn tick_fetch_inc(&mut self) -> u16 { let tick = self.owned().tick.get(); self.owned().tick.set(tick.wrapping_add(1)); tick } fn is_searching(&mut self) -> bool { self.owned().is_searching.get() } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
fn drop(&mut self) { if self.gone.get() { let inner = self.inner.take().unwrap(); std::mem::forget(inner); } } } impl<'a, T> Deref for DropNotGone<'a, T> { type Target = T; fn deref(&self) -> &Self::Target { self.inner.as_ref().unwrap() } } impl<'a, T> D...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1a7f6fb201c04e8bb02c6e59ddaabadceb8413c2/tokio/src/runtime/thread_pool/worker.rs
641
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:3
// unsafe is safe because we call Worker::new only once with each index in the pool unsafe { Worker::new(pool.clone(), index, park, Arc::clone(&launch_worker)) } }) .collect(); (pool, workers) } /// After how many ticks is the global queue polled. This helps to ensure /// fairness. ///...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
81
140
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:4
let executor = &**pool; let spawner = Spawner::new(pool.clone()); let entry = &mut self.entry; let launch_worker = &self.launch_worker; let blocking = &executor.blocking; let gone = &self.gone; let mut park = DropNotGone::new(self.park, gone); // Track the curr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
121
180
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:6
// The same argument applies here. Since we unset `current`, // the task's execution won't assume that it owns a worker any // more. When the task yields, entry will use its `Arc<Set>` // (which is fine and safe)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
201
260
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:7
// because we know that ob will set back to None before allow_blocking // is dropped. #[allow(clippy::useless_transmute)] std::mem::transmute::<_, *mut dyn FnMut()>(allow_blocking) })); l...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
241
300
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:8
current::set(&self.entry.pool, self.entry.index, f) } #[cfg(test)] #[allow(warnings)] pub(crate) fn tick(&mut self) { self.entry.tick(&mut *self.park, &self.gone); } } struct WorkerGone; struct Entry<P: 'static> { pool: Arc<Set<P>>, index: usize, } impl<P> Entry<P> where P: U...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
281
340
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:9
fn is_running(&mut self) -> bool { self.owned().is_running.get() } /// Returns `true` if the worker needs to park fn tick( &mut self, park: &mut impl Park<Unpark = P>, gone: &Cell<bool>, ) -> Result<bool, WorkerGone> { // Process all pending tasks in the local qu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
321
380
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:10
loop { let tick = self.tick_fetch_inc(); let task = if tick % GLOBAL_POLL_INTERVAL == 0 { // Sleep light... self.park_light(park); // Perform regularly scheduled maintenance work. self.maintenance(); if !self.is_r...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
361
420
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:11
/// Runs maintenance work such as free pending tasks and check the pool's /// state. fn maintenance(&mut self) { // Free any completed tasks self.drain_tasks_pending_drop(); // Update the pool state cache let closed = self.owned().work_queue.is_closed(); self.owned().is_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
401
460
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:12
} /// Returns `true` if the worker must check for any work. fn transition_to_parked(&mut self) -> bool { let idx = self.index; let is_searching = self.is_searching(); let ret = self .set() .idle() .transition_worker_to_parked(idx, is_searching); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
441
500
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:13
ret } } fn run_task(&mut self, task: Task<Shared<P>>, gone: &Cell<bool>) -> Result<(), WorkerGone> { if self.is_searching() { self.transition_from_searching(); } let executor = self.shared(); let task = task.run(&mut || { if gone.get() { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
481
540
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:14
fn park(&mut self, park: &mut impl Park<Unpark = P>) { if self.transition_to_parked() { // We are the final searching worker, check if any work arrived // before parking self.final_work_sweep(); } // The state has been transitioned to parked, we can now wait ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
521
580
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:15
for task in self.shared().pending_drop.drain() { unsafe { let owned = &mut *self.set().owned()[self.index].get(); owned.release_task(&task); } drop(task); } } /// Shutdown the worker. /// /// Once the shutdown flag has been obs...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
561
620
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:16
/// Increment the tick, returning the value from before the increment. fn tick_fetch_inc(&mut self) -> u16 { let tick = self.owned().tick.get(); self.owned().tick.set(tick.wrapping_add(1)); tick } fn is_searching(&mut self) -> bool { self.owned().is_searching.get() } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
601
660
tokio-rs/tokio:tokio/src/runtime/thread_pool/worker.rs:17
impl<'a, T> Drop for DropNotGone<'a, T> { fn drop(&mut self) { if self.gone.get() { let inner = self.inner.take().unwrap(); std::mem::forget(inner); } } } impl<'a, T> Deref for DropNotGone<'a, T> { type Target = T; fn deref(&self) -> &Self::Target { self....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/thread_pool/worker.rs
MIT
0da23aad772afb22db8edf73ac0f034c5ada3bde
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0da23aad772afb22db8edf73ac0f034c5ada3bde/tokio/src/runtime/thread_pool/worker.rs
641
661
tokio-rs/tokio:tokio/src/runtime/threadpool/async_await.rs:1
use std::future::Future; use super::Runtime; impl Runtime { /// Like `block_on`, but takes an `async` block pub fn block_on_async<F>(&mut self, future: F) -> F::Output where F: Future + Send + 'static, F::Output: Send + 'static, { use tokio_futures::compat; match self.b...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/async_await.rs
MIT
cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/src/runtime/threadpool/async_await.rs
1
18
tokio-rs/tokio:tokio/src/runtime/threadpool/async_await.rs:1
use super::Runtime; use std::future::Future; impl Runtime { /// Like `block_on`, but takes an `async` block pub fn block_on_async<F>(&mut self, future: F) -> F::Output where F: Future + Send + 'static, F::Output: Send + 'static, { use tokio_futures::compat; match self.b...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/async_await.rs
MIT
0e400af78c049c4b52fa4cb346237b43218b0ec9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0e400af78c049c4b52fa4cb346237b43218b0ec9/tokio/src/runtime/threadpool/async_await.rs
1
18
tokio-rs/tokio:tokio/src/runtime/threadpool/background.rs:1
//! Temporary reactor + timer that runs on a background thread. This it to make //! `block_on` work. use tokio_executor::current_thread::CurrentThread; use tokio_net::driver::{self, Reactor}; use tokio_sync::oneshot; use tokio_timer::clock::Clock; use tokio_timer::timer::{self, Timer}; use std::{io, thread}; #[deriv...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/background.rs
MIT
f1f61a3b15d17767b12bfd8c0c5712db1b089b0b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f1f61a3b15d17767b12bfd8c0c5712db1b089b0b/tokio/src/runtime/threadpool/background.rs
1
60
tokio-rs/tokio:tokio/src/runtime/threadpool/background.rs:1
//! Temporary reactor + timer that runs on a background thread. This it to make //! `block_on` work. use tokio_executor::current_thread::CurrentThread; use tokio_net::Reactor; use tokio_sync::oneshot; use tokio_timer::clock::Clock; use tokio_timer::timer::{self, Timer}; use std::{io, thread}; #[derive(Debug)] pub(cr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/background.rs
MIT
8538c25170240fa46313ffe9d4a9a2f9ba2536e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8538c25170240fa46313ffe9d4a9a2f9ba2536e5/tokio/src/runtime/threadpool/background.rs
1
60
tokio-rs/tokio:tokio/src/runtime/threadpool/background.rs:2
shutdown_tx, thread, }) } impl Background { pub(super) fn reactor(&self) -> &tokio_net::Handle { &self.reactor_handle } pub(super) fn timer(&self) -> &timer::Handle { &self.timer_handle } } impl Drop for Background { fn drop(&mut self) { let _ = self.shutdown_t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/background.rs
MIT
8538c25170240fa46313ffe9d4a9a2f9ba2536e5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8538c25170240fa46313ffe9d4a9a2f9ba2536e5/tokio/src/runtime/threadpool/background.rs
41
61
tokio-rs/tokio:tokio/src/runtime/threadpool/background.rs:1
//! Temporary reactor + timer that runs on a background thread. This it to make //! `block_on` work. use tokio_executor::current_thread::CurrentThread; use tokio_reactor::Reactor; use tokio_sync::oneshot; use tokio_timer::clock::Clock; use tokio_timer::timer::{self, Timer}; use std::{io, thread}; #[derive(Debug)] pu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/background.rs
MIT
9de7083be89bde2e26ee5bc4f3333f5c8d13762d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9de7083be89bde2e26ee5bc4f3333f5c8d13762d/tokio/src/runtime/threadpool/background.rs
1
60
tokio-rs/tokio:tokio/src/runtime/threadpool/background.rs:2
shutdown_tx, thread, }) } impl Background { pub(super) fn reactor(&self) -> &tokio_reactor::Handle { &self.reactor_handle } pub(super) fn timer(&self) -> &timer::Handle { &self.timer_handle } } impl Drop for Background { fn drop(&mut self) { let _ = self.shutdo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/background.rs
MIT
9de7083be89bde2e26ee5bc4f3333f5c8d13762d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9de7083be89bde2e26ee5bc4f3333f5c8d13762d/tokio/src/runtime/threadpool/background.rs
41
61
tokio-rs/tokio:tokio/src/runtime/threadpool/background.rs:1
//! Temporary reactor + timer that runs on a background thread. This it to make //! `block_on` work. use tokio_current_thread::CurrentThread; use tokio_reactor::Reactor; use tokio_sync::oneshot; use tokio_timer::clock::Clock; use tokio_timer::timer::{self, Timer}; use std::{io, thread}; #[derive(Debug)] pub(crate) s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/background.rs
MIT
6a125082e48c6e2334d64e4ebc5b6a988cf27b3f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6a125082e48c6e2334d64e4ebc5b6a988cf27b3f/tokio/src/runtime/threadpool/background.rs
1
60
tokio-rs/tokio:tokio/src/runtime/threadpool/background.rs:1
//! Temporary reactor + timer that runs on a background thread. This it to make //! `block_on` work. use tokio_current_thread::CurrentThread; use tokio_reactor::Reactor; use tokio_sync::oneshot; use tokio_timer::clock::Clock; use tokio_timer::timer::{self, Timer}; use std::{io, thread}; #[derive(Debug)] pub struct B...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/background.rs
MIT
9d3e5aac083fd7369bcc48b7f75472b6f8f87ea8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d3e5aac083fd7369bcc48b7f75472b6f8f87ea8/tokio/src/runtime/threadpool/background.rs
1
60
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:1
use crate::executor::thread_pool; use crate::net::driver::{self, Reactor}; use crate::runtime::threadpool::{Inner, Runtime}; use crate::timer::clock::{self, Clock}; use crate::timer::timer::{self, Timer}; use std::sync::{Arc, Mutex}; use std::{fmt, io}; /// Builds Tokio Runtime with custom configuration values. /// /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
c62ef2d232dea1535a8e22484fa2ca083f03e903
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/src/runtime/threadpool/builder.rs
1
60
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:2
/// ``` pub struct Builder { /// Thread pool specific builder thread_pool_builder: thread_pool::Builder, /// The number of worker threads num_threads: usize, /// To run after each worker thread starts after_start: Option<Arc<dyn Fn() + Send + Sync>>, /// To run before each worker thread s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
c62ef2d232dea1535a8e22484fa2ca083f03e903
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/src/runtime/threadpool/builder.rs
41
100
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:4
/// # pub fn main() { /// let rt = runtime::Builder::new() /// .name("my-pool") /// .build(); /// # } /// ``` pub fn name(&mut self, val: impl Into<String>) -> &mut Self { self.thread_pool_builder.name(val); self } /// Set the stack size (in bytes) for worker thr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
c62ef2d232dea1535a8e22484fa2ca083f03e903
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/src/runtime/threadpool/builder.rs
121
180
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:5
/// # Examples /// /// ``` /// # use tokio::runtime; /// /// # pub fn main() { /// let thread_pool = runtime::Builder::new() /// .after_start(|| { /// println!("thread started"); /// }) /// .build(); /// # } /// ``` pub fn after_start<F>(&mut self,...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
c62ef2d232dea1535a8e22484fa2ca083f03e903
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/src/runtime/threadpool/builder.rs
161
220
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:6
F: Fn() + Send + Sync + 'static, { self.before_stop = Some(Arc::new(f)); self } /// Create the configured `Runtime`. /// /// The returned `ThreadPool` instance is ready to spawn tasks. /// /// # Examples /// /// ``` /// # use tokio::runtime::Builder; /// # pu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
c62ef2d232dea1535a8e22484fa2ca083f03e903
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/src/runtime/threadpool/builder.rs
201
260
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:7
let around_timer_handles = timer_handles.clone(); let after_start = self.after_start.clone(); let before_stop = self.before_stop.clone(); let pool = self .thread_pool_builder .around_worker(move |index, next| { let _reactor = driver::set_default(&around_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
c62ef2d232dea1535a8e22484fa2ca083f03e903
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/src/runtime/threadpool/builder.rs
241
288
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:1
use crate::net::driver::{self, Reactor}; use crate::runtime::threadpool::{Inner, Runtime}; use crate::timer::clock::{self, Clock}; use crate::timer::timer::{self, Timer}; use tokio_executor::thread_pool; use std::sync::{Arc, Mutex}; use std::{fmt, io}; /// Builds Tokio Runtime with custom configuration values. /// /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
474befd23c368a34a5f45aab0f3945212109a803
github
async-runtime
https://github.com/tokio-rs/tokio/blob/474befd23c368a34a5f45aab0f3945212109a803/tokio/src/runtime/threadpool/builder.rs
1
60
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:2
/// } /// ``` pub struct Builder { /// Thread pool specific builder thread_pool_builder: thread_pool::Builder, /// The number of worker threads num_threads: usize, /// To run after each worker thread starts after_start: Option<Arc<dyn Fn() + Send + Sync>>, /// To run before each worker th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
474befd23c368a34a5f45aab0f3945212109a803
github
async-runtime
https://github.com/tokio-rs/tokio/blob/474befd23c368a34a5f45aab0f3945212109a803/tokio/src/runtime/threadpool/builder.rs
41
100
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:4
/// /// # pub fn main() { /// let rt = runtime::Builder::new() /// .name("my-pool") /// .build(); /// # } /// ``` pub fn name(&mut self, val: impl Into<String>) -> &mut Self { self.thread_pool_builder.name(val); self } /// Set the stack size (in bytes) for wo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
474befd23c368a34a5f45aab0f3945212109a803
github
async-runtime
https://github.com/tokio-rs/tokio/blob/474befd23c368a34a5f45aab0f3945212109a803/tokio/src/runtime/threadpool/builder.rs
121
180
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:5
/// /// # Examples /// /// ``` /// # use tokio::runtime; /// /// # pub fn main() { /// let thread_pool = runtime::Builder::new() /// .after_start(|| { /// println!("thread started"); /// }) /// .build(); /// # } /// ``` pub fn after_start<F>(&m...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
474befd23c368a34a5f45aab0f3945212109a803
github
async-runtime
https://github.com/tokio-rs/tokio/blob/474befd23c368a34a5f45aab0f3945212109a803/tokio/src/runtime/threadpool/builder.rs
161
220
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:6
where F: Fn() + Send + Sync + 'static, { self.before_stop = Some(Arc::new(f)); self } /// Create the configured `Runtime`. /// /// The returned `ThreadPool` instance is ready to spawn tasks. /// /// # Examples /// /// ``` /// # use tokio::runtime::Builder...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
474befd23c368a34a5f45aab0f3945212109a803
github
async-runtime
https://github.com/tokio-rs/tokio/blob/474befd23c368a34a5f45aab0f3945212109a803/tokio/src/runtime/threadpool/builder.rs
201
260
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:7
let around_reactor_handles = reactor_handles.clone(); let around_timer_handles = timer_handles.clone(); let after_start = self.after_start.clone(); let before_stop = self.before_stop.clone(); let pool = self .thread_pool_builder .around_worker(move |index, next|...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
474befd23c368a34a5f45aab0f3945212109a803
github
async-runtime
https://github.com/tokio-rs/tokio/blob/474befd23c368a34a5f45aab0f3945212109a803/tokio/src/runtime/threadpool/builder.rs
241
289
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:4
/// /// # pub fn main() { /// let rt = runtime::Builder::new() /// .name("my-pool") /// .build(); /// # } /// ``` pub fn name<S: Into<String>>(&mut self, val: S) -> &mut Self { self.thread_pool_builder.name(val); self } /// Set the stack size (in bytes) for w...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
227533d456fe32e48ffcd3796f1e6c8f9318b230
github
async-runtime
https://github.com/tokio-rs/tokio/blob/227533d456fe32e48ffcd3796f1e6c8f9318b230/tokio/src/runtime/threadpool/builder.rs
121
180
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:1
use super::{Inner, Runtime}; use crate::timer::clock::{self, Clock}; use crate::timer::timer::{self, Timer}; use tokio_executor::thread_pool; use tokio_net::driver::{self, Reactor}; use std::sync::{Arc, Mutex}; use std::{fmt, io}; /// Builds Tokio Runtime with custom configuration values. /// /// Methods can be chai...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
03a9378297c73c2e56a6d6b55db22b92427b850a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/03a9378297c73c2e56a6d6b55db22b92427b850a/tokio/src/runtime/threadpool/builder.rs
1
60
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:1
use super::{Inner, Runtime}; use crate::timer::clock::{self, Clock}; use crate::timer::timer::{self, Timer}; use tokio_executor::thread_pool; use tokio_net::driver::{self, Reactor}; use std::{fmt, io}; use std::sync::{Arc, Mutex}; /// Builds Tokio Runtime with custom configuration values. /// /// Methods can be chai...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
99940aeeb478e1c96959aed69561336ab067d0d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/99940aeeb478e1c96959aed69561336ab067d0d3/tokio/src/runtime/threadpool/builder.rs
1
60
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:2
/// } /// ``` pub struct Builder { /// Thread pool specific builder thread_pool_builder: thread_pool::Builder, /// The number of worker threads num_threads: usize, /// To run after each worker thread starts after_start: Option<Arc<dyn Fn() + Send + Sync>>, /// To run before each worker th...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
99940aeeb478e1c96959aed69561336ab067d0d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/99940aeeb478e1c96959aed69561336ab067d0d3/tokio/src/runtime/threadpool/builder.rs
41
100
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:6
/// # } /// ``` pub fn before_stop<F>(&mut self, f: F) -> &mut Self where F: Fn() + Send + Sync + 'static { self.before_stop = Some(Arc::new(f)); self } /// Create the configured `Runtime`. /// /// The returned `ThreadPool` instance is ready to spawn tasks. /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
99940aeeb478e1c96959aed69561336ab067d0d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/99940aeeb478e1c96959aed69561336ab067d0d3/tokio/src/runtime/threadpool/builder.rs
201
260
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:7
let clock = self.clock.clone(); let around_reactor_handles = reactor_handles.clone(); let around_timer_handles = timer_handles.clone(); let after_start = self.after_start.clone(); let before_stop = self.before_stop.clone(); let pool = self .thread_pool_builder ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
99940aeeb478e1c96959aed69561336ab067d0d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/99940aeeb478e1c96959aed69561336ab067d0d3/tokio/src/runtime/threadpool/builder.rs
241
297
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:8
} } impl Default for Builder { fn default() -> Self { Self::new() } } impl fmt::Debug for Builder { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("Builder") .field("thread_pool_builder", &self.thread_pool_builder) .field("after_start"...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
99940aeeb478e1c96959aed69561336ab067d0d3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/99940aeeb478e1c96959aed69561336ab067d0d3/tokio/src/runtime/threadpool/builder.rs
281
297
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:1
use super::{Inner, Runtime}; use crate::timer::clock::{self, Clock}; use crate::timer::timer::{self, Timer}; use tokio_executor::thread_pool; use tokio_net::driver::{self, Reactor}; use tracing_core as trace; use std::{fmt, io}; use std::sync::{Arc, Mutex}; /// Builds Tokio Runtime with custom configuration values. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
b8cee1a60ad99ef28ec494ae4230e2ef4399fcf9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b8cee1a60ad99ef28ec494ae4230e2ef4399fcf9/tokio/src/runtime/threadpool/builder.rs
1
60
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:2
/// // use runtime ... /// } /// ``` pub struct Builder { /// Thread pool specific builder thread_pool_builder: thread_pool::Builder, /// The number of worker threads num_threads: usize, /// To run after each worker thread starts after_start: Option<Arc<dyn Fn() + Send + Sync>>, /// T...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
b8cee1a60ad99ef28ec494ae4230e2ef4399fcf9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b8cee1a60ad99ef28ec494ae4230e2ef4399fcf9/tokio/src/runtime/threadpool/builder.rs
41
100
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:3
} /// Set the `Clock` instance that will be used by the runtime. pub fn clock(&mut self, clock: Clock) -> &mut Self { self.clock = clock; self } /// Set the maximum number of worker threads for the `Runtime`'s thread pool. /// /// This must be a number between 1 and 32,768 thou...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
b8cee1a60ad99ef28ec494ae4230e2ef4399fcf9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b8cee1a60ad99ef28ec494ae4230e2ef4399fcf9/tokio/src/runtime/threadpool/builder.rs
81
140
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:6
/// .build(); /// # } /// ``` pub fn before_stop<F>(&mut self, f: F) -> &mut Self where F: Fn() + Send + Sync + 'static { self.before_stop = Some(Arc::new(f)); self } /// Create the configured `Runtime`. /// /// The returned `ThreadPool` instance is ready to ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
b8cee1a60ad99ef28ec494ae4230e2ef4399fcf9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b8cee1a60ad99ef28ec494ae4230e2ef4399fcf9/tokio/src/runtime/threadpool/builder.rs
201
260
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:7
// Get a handle to the clock for the runtime. let clock = self.clock.clone(); // Get the current trace dispatcher. // TODO(eliza): when `tokio-trace-core` is stable enough to take a // public API dependency, we should allow users to set a custom // subscriber for the runtime. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
b8cee1a60ad99ef28ec494ae4230e2ef4399fcf9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b8cee1a60ad99ef28ec494ae4230e2ef4399fcf9/tokio/src/runtime/threadpool/builder.rs
241
300
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:8
.unwrap() }); Ok(Runtime { inner: Some(Inner { pool, reactor_handles, timer_handles, trace, }), }) } } impl Default for Builder { fn default() -> Self { Self::new() } } impl fmt::De...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
b8cee1a60ad99ef28ec494ae4230e2ef4399fcf9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b8cee1a60ad99ef28ec494ae4230e2ef4399fcf9/tokio/src/runtime/threadpool/builder.rs
281
308
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:1
use super::{Inner, Runtime}; use tokio_executor::thread_pool; use tokio_net::driver::{self, Reactor}; use tokio_timer::clock::{self, Clock}; use tokio_timer::timer::{self, Timer}; use tracing_core as trace; use std::{fmt, io}; use std::sync::{Arc, Mutex}; /// Builds Tokio Runtime with custom configuration values. //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
ed5a94eb2db95b7cc142045fbbd5d68c6276e04e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ed5a94eb2db95b7cc142045fbbd5d68c6276e04e/tokio/src/runtime/threadpool/builder.rs
1
60
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:6
/// .build(); /// # } /// ``` pub fn before_stop<F>(&mut self, f: F) -> &mut Self where F: Fn() + Send + Sync + 'static { self.before_stop = Some(Arc::new(f)); self } /// Create the configured `Runtime`. /// /// The returned `ThreadPool` instance is ready to ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
ed5a94eb2db95b7cc142045fbbd5d68c6276e04e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ed5a94eb2db95b7cc142045fbbd5d68c6276e04e/tokio/src/runtime/threadpool/builder.rs
201
260
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:1
use super::{background, Inner, Runtime}; use tokio_executor::threadpool; use tokio_net::driver::{self, Reactor}; use tokio_timer::clock::{self, Clock}; use tokio_timer::timer::{self, Timer}; use num_cpus; use tracing_core as trace; use std::io; use std::sync::Mutex; use std::time::Duration; use std::any::Any; /// Bu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
d1f60ac4c69792211f9c9f3bcff1559bc0cb837a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1f60ac4c69792211f9c9f3bcff1559bc0cb837a/tokio/src/runtime/threadpool/builder.rs
1
60
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:2
/// .core_threads(4) /// .keep_alive(Some(Duration::from_secs(60))) /// .name_prefix("my-custom-name-") /// .stack_size(3 * 1024 * 1024) /// .build() /// .unwrap(); /// /// // use runtime ... /// } /// ``` #[derive(Debug)] pub struct Builder { /// Thread pool spec...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
d1f60ac4c69792211f9c9f3bcff1559bc0cb837a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1f60ac4c69792211f9c9f3bcff1559bc0cb837a/tokio/src/runtime/threadpool/builder.rs
41
100
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:3
/// Set the `Clock` instance that will be used by the runtime. pub fn clock(&mut self, clock: Clock) -> &mut Self { self.clock = clock; self } /// Sets a callback to handle panics in futures. /// /// The callback is triggered when a panic during a future bubbles up to /// Tokio....
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
d1f60ac4c69792211f9c9f3bcff1559bc0cb837a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1f60ac4c69792211f9c9f3bcff1559bc0cb837a/tokio/src/runtime/threadpool/builder.rs
81
140
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:7
/// ``` pub fn stack_size(&mut self, val: usize) -> &mut Self { self.threadpool_builder.stack_size(val); self } /// Execute function `f` after each thread is started but before it starts /// doing work. /// /// This is intended for bookkeeping and monitoring use cases. /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
d1f60ac4c69792211f9c9f3bcff1559bc0cb837a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1f60ac4c69792211f9c9f3bcff1559bc0cb837a/tokio/src/runtime/threadpool/builder.rs
241
300
tokio-rs/tokio:tokio/src/runtime/threadpool/builder.rs:8
/// # pub fn main() { /// let thread_pool = runtime::Builder::new() /// .before_stop(|| { /// println!("thread stopping"); /// }) /// .build(); /// # } /// ``` pub fn before_stop<F>(&mut self, f: F) -> &mut Self where F: Fn() + Send + Sync + 'static { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/runtime/threadpool/builder.rs
MIT
d1f60ac4c69792211f9c9f3bcff1559bc0cb837a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1f60ac4c69792211f9c9f3bcff1559bc0cb837a/tokio/src/runtime/threadpool/builder.rs
281
340