summaryrefslogtreecommitdiffstats
path: root/tokio/src/runtime/builder.rs
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2019-11-16 07:19:45 -0800
committerGitHub <noreply@github.com>2019-11-16 07:19:45 -0800
commit3f0eabe7798de624f5ee9c7562803bfb97e6088f (patch)
tree6458345730f7eae674ec1e7ea82f120a5f1b70bc /tokio/src/runtime/builder.rs
parent1474794055e291c544c3c95d6381d549cefbd7d5 (diff)
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.
Diffstat (limited to 'tokio/src/runtime/builder.rs')
-rw-r--r--tokio/src/runtime/builder.rs32
1 files changed, 16 insertions, 16 deletions
diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs
index 66c9e166..72cbc9c4 100644
--- a/tokio/src/runtime/builder.rs
+++ b/tokio/src/runtime/builder.rs
@@ -61,7 +61,7 @@ pub struct Builder {
enum Kind {
Shell,
#[cfg(feature = "rt-core")]
- CurrentThread,
+ Basic,
#[cfg(feature = "rt-full")]
ThreadPool,
}
@@ -121,19 +121,19 @@ impl Builder {
self
}
- /// Use only the current thread for executing tasks.
+ /// Use a simpler scheduler that runs all tasks on the current-thread.
///
/// The executor and all necessary drivers will all be run on the current
/// thread during `block_on` calls.
#[cfg(feature = "rt-core")]
- pub fn current_thread(&mut self) -> &mut Self {
- self.kind = Kind::CurrentThread;
+ pub fn basic_scheduler(&mut self) -> &mut Self {
+ self.kind = Kind::Basic;
self
}
- /// Use a thread-pool for executing tasks.
+ /// Use a multi-threaded scheduler for executing tasks.
#[cfg(feature = "rt-full")]
- pub fn thread_pool(&mut self) -> &mut Self {
+ pub fn threaded_scheduler(&mut self) -> &mut Self {
self.kind = Kind::ThreadPool;
self
}
@@ -252,15 +252,15 @@ impl Builder {
/// ```
pub fn build(&mut self) -> io::Result<Runtime> {
match self.kind {
- Kind::Shell => self.build_shell(),
+ Kind::Shell => self.build_shell_runtime(),
#[cfg(feature = "rt-core")]
- Kind::CurrentThread => self.build_current_thread(),
+ Kind::Basic => self.build_basic_runtime(),
#[cfg(feature = "rt-full")]
- Kind::ThreadPool => self.build_threadpool(),
+ Kind::ThreadPool => self.build_threaded_runtime(),
}
}
- fn build_shell(&mut self) -> io::Result<Runtime> {
+ fn build_shell_runtime(&mut self) -> io::Result<Runtime> {
use crate::runtime::Kind;
let clock = time::create_clock();
@@ -289,8 +289,8 @@ impl Builder {
}
#[cfg(feature = "rt-core")]
- fn build_current_thread(&mut self) -> io::Result<Runtime> {
- use crate::runtime::{CurrentThread, Kind};
+ fn build_basic_runtime(&mut self) -> io::Result<Runtime> {
+ use crate::runtime::{BasicScheduler, Kind};
let clock = time::create_clock();
@@ -305,7 +305,7 @@ impl Builder {
// there are no futures ready to do something, it'll let the timer or
// the reactor to generate some new stimuli for the futures to continue
// in their life.
- let scheduler = CurrentThread::new(driver);
+ let scheduler = BasicScheduler::new(driver);
let spawner = scheduler.spawner();
// Blocking pool
@@ -313,9 +313,9 @@ impl Builder {
let blocking_spawner = blocking_pool.spawner().clone();
Ok(Runtime {
- kind: Kind::CurrentThread(scheduler),
+ kind: Kind::Basic(scheduler),
handle: Handle {
- kind: handle::Kind::CurrentThread(spawner),
+ kind: handle::Kind::Basic(spawner),
io_handles,
time_handles,
clock,
@@ -326,7 +326,7 @@ impl Builder {
}
#[cfg(feature = "rt-full")]
- fn build_threadpool(&mut self) -> io::Result<Runtime> {
+ fn build_threaded_runtime(&mut self) -> io::Result<Runtime> {
use crate::runtime::{Kind, ThreadPool};
use std::sync::Mutex;