Skip to content

Commit

Permalink
Try to fix types to work in all feature combinations.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorendorff committed Oct 26, 2022
1 parent ea25baf commit 976004f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 2 additions & 3 deletions tokio/src/runtime/blocking/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ impl Spawner {
R: Send + 'static,
{
let fut = BlockingTask::new(func);
#[cfg(feature = "test-util")]
let fut = crate::time::inhibit_auto_advance(fut);
let id = task::Id::next();
#[cfg(all(tokio_unstable, feature = "tracing"))]
let fut = {
Expand All @@ -337,9 +339,6 @@ impl Spawner {
#[cfg(not(all(tokio_unstable, feature = "tracing")))]
let _ = name;

#[cfg(feature = "test-util")]
let fut = crate::time::inhibit_auto_advance(fut);

let (task, handle) = task::unowned(fut, NoopSchedule, id);

let spawned = self.spawn_task(Task::new(task, is_mandatory), rt);
Expand Down
5 changes: 4 additions & 1 deletion tokio/src/time/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ cfg_test_util! {
/// it returns `Ready` or is dropped.
///
/// This is a no-op when called from outside the Tokio runtime.
pub(crate) fn inhibit_auto_advance<F: Future>(fut: F) -> impl Future<Output = F::Output> {
pub(crate) fn inhibit_auto_advance<F>(fut: F) -> impl Future<Output = F::Output> + Send + 'static
where
F: Future + Send + 'static,
{
// Bump the inhibit count immediately, not inside the async block, to
// avoid a race condition when used by spawn_blocking.
let guard = clock().map(|clock| {
Expand Down

0 comments on commit 976004f

Please sign in to comment.