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:
Carl Lerche
2019-11-16 07:19:45 -08:00
committed by GitHub
parent 1474794055
commit 3f0eabe779
16 changed files with 122 additions and 115 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ fn run_test() {
let finished_clone = finished.clone();
thread::spawn(move || {
let mut rt = runtime::Builder::new().current_thread().build().unwrap();
let mut rt = runtime::Builder::new().basic_scheduler().build().unwrap();
let mut futures = FuturesOrdered::new();
rt.block_on(async {
@@ -28,7 +28,7 @@ fn spawned_task_does_not_progress_without_block_on() {
fn rt() -> Runtime {
tokio::runtime::Builder::new()
.current_thread()
.basic_scheduler()
.build()
.unwrap()
}
+2 -2
View File
@@ -4,12 +4,12 @@
macro_rules! rt_test {
($($t:tt)*) => {
mod current_thread {
mod basic_scheduler {
$($t)*
fn rt() -> Runtime {
tokio::runtime::Builder::new()
.current_thread()
.basic_scheduler()
.build()
.unwrap()
}
@@ -16,7 +16,10 @@ use std::task::{Context, Poll};
#[test]
fn single_thread() {
// No panic when starting a runtime w/ a single thread
let _ = runtime::Builder::new().thread_pool().num_threads(1).build();
let _ = runtime::Builder::new()
.threaded_scheduler()
.num_threads(1)
.build();
}
#[test]
@@ -185,7 +188,7 @@ fn drop_threadpool_drops_futures() {
let b = num_dec.clone();
let rt = runtime::Builder::new()
.thread_pool()
.threaded_scheduler()
.after_start(move || {
a.fetch_add(1, Relaxed);
})
@@ -224,7 +227,7 @@ fn after_start_and_before_stop_is_called() {
let after_inner = after_start.clone();
let before_inner = before_stop.clone();
let mut rt = tokio::runtime::Builder::new()
.thread_pool()
.threaded_scheduler()
.after_start(move || {
after_inner.clone().fetch_add(1, Ordering::Relaxed);
})
+1 -1
View File
@@ -37,7 +37,7 @@ fn dropping_loops_does_not_cause_starvation() {
fn rt() -> Runtime {
tokio::runtime::Builder::new()
.current_thread()
.basic_scheduler()
.build()
.unwrap()
}
+1 -1
View File
@@ -47,7 +47,7 @@ fn multi_loop() {
fn rt() -> Runtime {
tokio::runtime::Builder::new()
.current_thread()
.basic_scheduler()
.build()
.unwrap()
}
+2 -2
View File
@@ -24,10 +24,10 @@ fn timer_with_threaded_runtime() {
}
#[test]
fn timer_with_current_thread_runtime() {
fn timer_with_basic_scheduler() {
use tokio::runtime::Builder;
let mut rt = Builder::new().current_thread().build().unwrap();
let mut rt = Builder::new().basic_scheduler().build().unwrap();
let (tx, rx) = mpsc::channel();
rt.block_on(async move {