about summary refs log tree commit diff
path: root/src/libcore/task
diff options
context:
space:
mode:
authorJosef Reinhard Brandl <mail@josefbrandl.de>2018-08-06 10:22:13 +0200
committerJosef Reinhard Brandl <mail@josefbrandl.de>2018-08-06 12:18:47 +0200
commit60aa11df4c1c4fef9122a025c31819e1cf3e456a (patch)
tree8d88b328f034177a73945ea0897e9efc56e6c181 /src/libcore/task
parentaa1e6db70900cf5d11a843bc4234de0548677aba (diff)
downloadrust-60aa11df4c1c4fef9122a025c31819e1cf3e456a.tar.gz
rust-60aa11df4c1c4fef9122a025c31819e1cf3e456a.zip
Rename Executor trait to Spawn
Diffstat (limited to 'src/libcore/task')
-rw-r--r--src/libcore/task/context.rs44
-rw-r--r--src/libcore/task/mod.rs6
-rw-r--r--src/libcore/task/spawn.rs (renamed from src/libcore/task/executor.rs)15
3 files changed, 33 insertions, 32 deletions
diff --git a/src/libcore/task/context.rs b/src/libcore/task/context.rs
index 121f93b666b..5a29c8528ef 100644
--- a/src/libcore/task/context.rs
+++ b/src/libcore/task/context.rs
@@ -13,7 +13,7 @@
             issue = "50547")]
 
 use fmt;
-use super::{Executor, Waker, LocalWaker};
+use super::{Spawn, Waker, LocalWaker};
 
 /// Information about the currently-running task.
 ///
@@ -21,7 +21,7 @@ use super::{Executor, Waker, LocalWaker};
 /// when performing a single `poll` step on a task.
 pub struct Context<'a> {
     local_waker: &'a LocalWaker,
-    executor: &'a mut dyn Executor,
+    spawner: &'a mut dyn Spawn,
 }
 
 impl<'a> fmt::Debug for Context<'a> {
@@ -32,13 +32,14 @@ impl<'a> fmt::Debug for Context<'a> {
 }
 
 impl<'a> Context<'a> {
-    /// Create a new task `Context` with the provided `local_waker`, `waker`, and `executor`.
+    /// Create a new task `Context` with the provided `local_waker`, `waker`,
+    /// and `spawner`.
     #[inline]
-    pub fn new(local_waker: &'a LocalWaker, executor: &'a mut dyn Executor) -> Context<'a> {
-        Context {
-            local_waker,
-            executor,
-        }
+    pub fn new(
+        local_waker: &'a LocalWaker,
+        spawner: &'a mut dyn Spawn,
+    ) -> Context<'a> {
+        Context { local_waker, spawner }
     }
 
     /// Get the `LocalWaker` associated with the current task.
@@ -53,40 +54,45 @@ impl<'a> Context<'a> {
         unsafe { &*(self.local_waker as *const LocalWaker as *const Waker) }
     }
 
-    /// Get the default executor associated with this task.
+    /// Get the spawner associated with this task.
     ///
     /// This method is useful primarily if you want to explicitly handle
     /// spawn failures.
     #[inline]
-    pub fn executor(&mut self) -> &mut dyn Executor {
-        self.executor
+    pub fn spawner(&mut self) -> &mut dyn Spawn {
+        self.spawner
     }
 
-    /// Produce a context like the current one, but using the given waker instead.
+    /// Produce a context like the current one, but using the given waker
+    /// instead.
     ///
     /// This advanced method is primarily used when building "internal
     /// schedulers" within a task, where you want to provide some customized
     /// wakeup logic.
     #[inline]
-    pub fn with_waker<'b>(&'b mut self, local_waker: &'b LocalWaker) -> Context<'b> {
+    pub fn with_waker<'b>(
+        &'b mut self,
+        local_waker: &'b LocalWaker,
+    ) -> Context<'b> {
         Context {
             local_waker,
-            executor: self.executor,
+            spawner: self.spawner,
         }
     }
 
-    /// Produce a context like the current one, but using the given executor
+    /// Produce a context like the current one, but using the given spawner
     /// instead.
     ///
     /// This advanced method is primarily used when building "internal
     /// schedulers" within a task.
     #[inline]
-    pub fn with_executor<'b, E>(&'b mut self, executor: &'b mut E) -> Context<'b>
-        where E: Executor
-    {
+    pub fn with_spawner<'b, Sp: Spawn>(
+        &'b mut self,
+        spawner: &'b mut Sp,
+    ) -> Context<'b> {
         Context {
             local_waker: self.local_waker,
-            executor,
+            spawner,
         }
     }
 }
diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs
index c4f07536164..f51e5f7ce0e 100644
--- a/src/libcore/task/mod.rs
+++ b/src/libcore/task/mod.rs
@@ -17,10 +17,8 @@
 mod context;
 pub use self::context::Context;
 
-mod executor;
-pub use self::executor::{
-  Executor, SpawnErrorKind, SpawnObjError, SpawnLocalObjError
-};
+mod spawn;
+pub use self::spawn::{Spawn, SpawnErrorKind, SpawnObjError, SpawnLocalObjError};
 
 mod poll;
 pub use self::poll::Poll;
diff --git a/src/libcore/task/executor.rs b/src/libcore/task/spawn.rs
index affcbf464da..58ee85d232b 100644
--- a/src/libcore/task/executor.rs
+++ b/src/libcore/task/spawn.rs
@@ -15,16 +15,13 @@
 use fmt;
 use future::{FutureObj, LocalFutureObj};
 
-/// A task executor.
+/// Spawns tasks that poll futures to completion onto its associated task
+/// executor.
 ///
-/// Futures are polled until completion by tasks, a kind of lightweight
-/// "thread". A *task executor* is responsible for the creation of these tasks
-/// and the coordination of their execution on real operating system threads. In
-/// particular, whenever a task signals that it can make further progress via a
-/// wake-up notification, it is the responsibility of the task executor to put
-/// the task into a queue to continue executing it, i.e. polling the future in
-/// it, later.
-pub trait Executor {
+/// The term "task" refers to a kind of lightweight "thread". Task executors
+/// are responsible for scheduling the execution of tasks on operating system
+/// threads.
+pub trait Spawn {
     /// Spawns a new task with the given future. The future will be polled until
     /// completion.
     ///