From 1db412d2c35d13b9d4b8ab28ca56de5b77abff71 Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep Date: Tue, 16 Nov 2021 11:16:30 +0100 Subject: Update to 1.14.0 Test: atest Change-Id: I713529f5ba957c212f50bde27b4428612dbcdefd --- src/runtime/blocking/pool.rs | 21 ++++++++++----------- src/runtime/blocking/shutdown.rs | 4 ++-- src/runtime/blocking/task.rs | 4 ++-- 3 files changed, 14 insertions(+), 15 deletions(-) (limited to 'src/runtime/blocking') diff --git a/src/runtime/blocking/pool.rs b/src/runtime/blocking/pool.rs index 0c23bb0..77ab495 100644 --- a/src/runtime/blocking/pool.rs +++ b/src/runtime/blocking/pool.rs @@ -8,7 +8,6 @@ use crate::runtime::builder::ThreadNameFn; use crate::runtime::context; use crate::runtime::task::{self, JoinHandle}; use crate::runtime::{Builder, Callback, Handle}; -use crate::util::error::CONTEXT_MISSING_ERROR; use std::collections::{HashMap, VecDeque}; use std::fmt; @@ -25,28 +24,28 @@ pub(crate) struct Spawner { } struct Inner { - /// State shared between worker threads + /// State shared between worker threads. shared: Mutex, /// Pool threads wait on this. condvar: Condvar, - /// Spawned threads use this name + /// Spawned threads use this name. thread_name: ThreadNameFn, - /// Spawned thread stack size + /// Spawned thread stack size. stack_size: Option, - /// Call after a thread starts + /// Call after a thread starts. after_start: Option, - /// Call before a thread stops + /// Call before a thread stops. before_stop: Option, - // Maximum number of threads + // Maximum number of threads. thread_cap: usize, - // Customizable wait timeout + // Customizable wait timeout. keep_alive: Duration, } @@ -67,7 +66,7 @@ struct Shared { /// calling shutdown handles joining on these. worker_threads: HashMap>, /// This is a counter used to iterate worker_threads in a consistent order (for loom's - /// benefit) + /// benefit). worker_thread_index: usize, } @@ -75,13 +74,13 @@ type Task = task::UnownedTask; const KEEP_ALIVE: Duration = Duration::from_secs(10); -/// Run the provided function on an executor dedicated to blocking operations. +/// Runs the provided function on an executor dedicated to blocking operations. pub(crate) fn spawn_blocking(func: F) -> JoinHandle where F: FnOnce() -> R + Send + 'static, R: Send + 'static, { - let rt = context::current().expect(CONTEXT_MISSING_ERROR); + let rt = context::current(); rt.spawn_blocking(func) } diff --git a/src/runtime/blocking/shutdown.rs b/src/runtime/blocking/shutdown.rs index 0cf2285..e6f4674 100644 --- a/src/runtime/blocking/shutdown.rs +++ b/src/runtime/blocking/shutdown.rs @@ -10,7 +10,7 @@ use std::time::Duration; #[derive(Debug, Clone)] pub(super) struct Sender { - tx: Arc>, + _tx: Arc>, } #[derive(Debug)] @@ -20,7 +20,7 @@ pub(super) struct Receiver { pub(super) fn channel() -> (Sender, Receiver) { let (tx, rx) = oneshot::channel(); - let tx = Sender { tx: Arc::new(tx) }; + let tx = Sender { _tx: Arc::new(tx) }; let rx = Receiver { rx }; (tx, rx) diff --git a/src/runtime/blocking/task.rs b/src/runtime/blocking/task.rs index ee2d8d6..0b7803a 100644 --- a/src/runtime/blocking/task.rs +++ b/src/runtime/blocking/task.rs @@ -2,13 +2,13 @@ use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; -/// Converts a function to a future that completes on poll +/// Converts a function to a future that completes on poll. pub(crate) struct BlockingTask { func: Option, } impl BlockingTask { - /// Initializes a new blocking task from the given function + /// Initializes a new blocking task from the given function. pub(crate) fn new(func: T) -> BlockingTask { BlockingTask { func: Some(func) } } -- cgit v1.2.3