mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +02:00
runtime: rename current_thread -> basic_scheduler (#1769)
It no longer supports executing !Send futures. The use case for It is wanting a “light” runtime. There will be “local” task execution using a different strategy coming later. This patch also renames `thread_pool` -> `threaded_scheduler`, but only in public APIs for now.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use tokio::runtime::Runtime;
|
||||
use tokio::sync::oneshot;
|
||||
use tokio_test::{assert_err, assert_ok};
|
||||
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
#[test]
|
||||
fn spawned_task_does_not_progress_without_block_on() {
|
||||
let (tx, mut rx) = oneshot::channel();
|
||||
|
||||
let mut rt = rt();
|
||||
|
||||
rt.spawn(async move {
|
||||
assert_ok!(tx.send("hello"));
|
||||
});
|
||||
|
||||
thread::sleep(Duration::from_millis(50));
|
||||
|
||||
assert_err!(rx.try_recv());
|
||||
|
||||
let out = rt.block_on(async { assert_ok!(rx.await) });
|
||||
|
||||
assert_eq!(out, "hello");
|
||||
}
|
||||
|
||||
fn rt() -> Runtime {
|
||||
tokio::runtime::Builder::new()
|
||||
.basic_scheduler()
|
||||
.build()
|
||||
.unwrap()
|
||||
}
|
||||
Reference in New Issue
Block a user