Skip to content

Commit 4a775eb

Browse files
authored
Merge pull request #25 from Neo-Zhixing/unblock_task
unblock returns Task
2 parents 2bb7954 + 501cfc2 commit 4a775eb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ use std::thread;
9393
use std::time::Duration;
9494

9595
use async_channel::{bounded, Receiver};
96-
use async_task::{Runnable, Task};
96+
use async_task::Runnable;
97+
pub use async_task::Task;
9798
use atomic_waker::AtomicWaker;
9899
use futures_lite::{future, prelude::*, ready};
99100
use once_cell::sync::Lazy;
@@ -267,12 +268,12 @@ impl Executor {
267268
/// let out = unblock(|| Command::new("dir").output()).await?;
268269
/// # std::io::Result::Ok(()) });
269270
/// ```
270-
pub async fn unblock<T, F>(f: F) -> T
271+
pub fn unblock<T, F>(f: F) -> Task<T>
271272
where
272273
F: FnOnce() -> T + Send + 'static,
273274
T: Send + 'static,
274275
{
275-
Executor::spawn(async move { f() }).await
276+
Executor::spawn(async move { f() })
276277
}
277278

278279
/// Runs blocking I/O on a thread pool.

0 commit comments

Comments
 (0)