Tokio will keep a rolling MSRV (minimum supported rust version) policy of **at
least** 6 months. When increasing the MSRV, the new Rust version must have been
-released at least six months ago. The current MSRV is 1.70.
+released at least six months ago. The current MSRV is 1.71.
Note that the MSRV is not increased automatically, and only as part of a minor
release. The MSRV history for past minor releases can be found below:
- * 1.39 to now - Rust 1.70
+ * 1.48 to now - Rust 1.71
+ * 1.39 to 1.47 - Rust 1.70
* 1.30 to 1.38 - Rust 1.63
* 1.27 to 1.29 - Rust 1.56
* 1.17 to 1.26 - Rust 1.49
#[cfg(not(loom))]
pub(crate) mod rand {
use std::collections::hash_map::RandomState;
- use std::hash::{BuildHasher, Hash, Hasher};
+ use std::hash::BuildHasher;
use std::sync::atomic::AtomicU32;
use std::sync::atomic::Ordering::Relaxed;
static COUNTER: AtomicU32 = AtomicU32::new(1);
pub(crate) fn seed() -> u64 {
- let rand_state = RandomState::new();
-
- let mut hasher = rand_state.build_hasher();
-
// Hash some unique-ish data to generate some new state
- COUNTER.fetch_add(1, Relaxed).hash(&mut hasher);
-
- // Get the seed
- hasher.finish()
+ RandomState::new().hash_one(COUNTER.fetch_add(1, Relaxed))
}
}
use std::collections::hash_map::RandomState;
use std::fmt;
use std::future::Future;
-use std::hash::{BuildHasher, Hash, Hasher};
+use std::hash::{BuildHasher, Hash};
use std::marker::PhantomData;
use tokio::runtime::Handle;
use tokio::task::{AbortHandle, Id, JoinError, JoinSet, LocalSet};
fn insert(&mut self, mut key: K, mut abort: AbortHandle) {
let hash_builder = self.hashes_by_task.hasher();
- let hash = hash_one(hash_builder, &key);
+ let hash = hash_builder.hash_one(&key);
let id = abort.id();
// Insert the new key into the map of tasks by keys.
let entry =
self.tasks_by_key
- .entry(hash, |(k, _)| *k == key, |(k, _)| hash_one(hash_builder, k));
+ .entry(hash, |(k, _)| *k == key, |(k, _)| hash_builder.hash_one(k));
match entry {
Entry::Occupied(occ) => {
// There was a previous task spawned with the same key! Cancel
/// ```
#[inline]
pub fn reserve(&mut self, additional: usize) {
- let hash_builder = self.hashes_by_task.hasher();
- self.tasks_by_key
- .reserve(additional, |(k, _)| hash_one(hash_builder, k));
+ self.tasks_by_key.reserve(additional, |(k, _)| {
+ self.hashes_by_task.hasher().hash_one(k)
+ });
self.hashes_by_task.reserve(additional);
}
#[inline]
pub fn shrink_to_fit(&mut self) {
self.hashes_by_task.shrink_to_fit();
- let hash_builder = self.hashes_by_task.hasher();
self.tasks_by_key
- .shrink_to_fit(|(k, _)| hash_one(hash_builder, k));
+ .shrink_to_fit(|(k, _)| self.hashes_by_task.hasher().hash_one(k));
}
/// Shrinks the capacity of the map with a lower limit. It will drop
#[inline]
pub fn shrink_to(&mut self, min_capacity: usize) {
self.hashes_by_task.shrink_to(min_capacity);
- let hash_builder = self.hashes_by_task.hasher();
- self.tasks_by_key
- .shrink_to(min_capacity, |(k, _)| hash_one(hash_builder, k))
+ self.tasks_by_key.shrink_to(min_capacity, |(k, _)| {
+ self.hashes_by_task.hasher().hash_one(k)
+ })
}
/// Look up a task in the map by its key, returning the key and abort handle.
Q: ?Sized + Hash + Eq,
K: Borrow<Q>,
{
- let hash_builder = self.hashes_by_task.hasher();
- let hash = hash_one(hash_builder, key);
+ let hash = self.hashes_by_task.hasher().hash_one(key);
self.tasks_by_key.find(hash, |(k, _)| k.borrow() == key)
}
}
}
-/// Returns the hash for a given key.
-#[inline]
-fn hash_one<S, Q>(hash_builder: &S, key: &Q) -> u64
-where
- Q: ?Sized + Hash,
- S: BuildHasher,
-{
- let mut hasher = hash_builder.build_hasher();
- key.hash(&mut hasher);
- hasher.finish()
-}
-
impl<K, V, S> JoinMap<K, V, S>
where
V: 'static,
Tokio will keep a rolling MSRV (minimum supported rust version) policy of **at
least** 6 months. When increasing the MSRV, the new Rust version must have been
-released at least six months ago. The current MSRV is 1.70.
+released at least six months ago. The current MSRV is 1.71.
Note that the MSRV is not increased automatically, and only as part of a minor
release. The MSRV history for past minor releases can be found below:
- * 1.39 to now - Rust 1.70
+ * 1.48 to now - Rust 1.71
+ * 1.39 to 1.47 - Rust 1.70
* 1.30 to 1.38 - Rust 1.63
* 1.27 to 1.29 - Rust 1.56
* 1.17 to 1.26 - Rust 1.49