mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-25 00:00:18 +02:00
rt: add runtime::context to unify thread-locals (#5143)
This patch is the first step towards unifying all the thread-local variables spread out across Tokio. A new `Context` struct is added which will be used to replace the various thread-locals that exist today. Initially, `Context` only holds the current runtime handle and the random number generator. Further PRs will add other thread-local state. A previous PR removed `runtime::context`. At that time, `runtime::context` was used as an extra layer to access the various runtime driver handles. This version of `runtime::context` serves a different purpose (unifying all the thread-locals).
This commit is contained in:
@@ -7,7 +7,6 @@ use crate::runtime::blocking::{shutdown, BlockingTask};
|
||||
use crate::runtime::builder::ThreadNameFn;
|
||||
use crate::runtime::task::{self, JoinHandle};
|
||||
use crate::runtime::{Builder, Callback, Handle};
|
||||
use crate::util::{replace_thread_rng, RngSeedGenerator};
|
||||
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::fmt;
|
||||
@@ -48,9 +47,6 @@ struct Inner {
|
||||
|
||||
// Customizable wait timeout.
|
||||
keep_alive: Duration,
|
||||
|
||||
// Random number seed
|
||||
seed_generator: RngSeedGenerator,
|
||||
}
|
||||
|
||||
struct Shared {
|
||||
@@ -185,7 +181,6 @@ impl BlockingPool {
|
||||
before_stop: builder.before_stop.clone(),
|
||||
thread_cap,
|
||||
keep_alive,
|
||||
seed_generator: builder.seed_generator.next_generator(),
|
||||
}),
|
||||
},
|
||||
shutdown_rx,
|
||||
@@ -435,8 +430,6 @@ impl Inner {
|
||||
if let Some(f) = &self.after_start {
|
||||
f()
|
||||
}
|
||||
// We own this thread so there is no need to replace the RngSeed once we're done.
|
||||
let _ = replace_thread_rng(self.seed_generator.next_seed());
|
||||
|
||||
let mut shared = self.shared.lock();
|
||||
let mut join_on_thread = None;
|
||||
|
||||
Reference in New Issue
Block a user