summaryrefslogtreecommitdiffstats
path: root/tokio/src/signal
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2019-11-01 13:18:52 -0700
committerGitHub <noreply@github.com>2019-11-01 13:18:52 -0700
commitd70c928d88dff9e3e8d673b8ee02bce131598550 (patch)
tree6b079db2f80bd61764203a32ffe48769d18c1386 /tokio/src/signal
parent742d89b0f333150f6a550ae7840235851f4eb069 (diff)
runtime: merge multi & single threaded runtimes (#1716)
Simplify Tokio's runtime construct by combining both Runtime variants into a single type. The execution style can be controlled by a configuration setting on `Builder`. The implication of this change is that there is no longer any way to spawn `!Send` futures. This, however, is a temporary limitation. A different strategy will be employed for supporting `!Send` futures. Included in this patch is a rework of `task::JoinHandle` to support using this type from both the thread-pool and current-thread executors.
Diffstat (limited to 'tokio/src/signal')
-rw-r--r--tokio/src/signal/registry.rs8
-rw-r--r--tokio/src/signal/windows.rs13
2 files changed, 16 insertions, 5 deletions
diff --git a/tokio/src/signal/registry.rs b/tokio/src/signal/registry.rs
index e70d0495..d608539c 100644
--- a/tokio/src/signal/registry.rs
+++ b/tokio/src/signal/registry.rs
@@ -178,13 +178,13 @@ where
#[cfg(all(test, not(loom)))]
mod tests {
use super::*;
- use crate::runtime::current_thread::Runtime;
+ use crate::runtime::{self, Runtime};
use crate::sync::{mpsc, oneshot};
use futures::{future, StreamExt};
#[test]
fn smoke() {
- let mut rt = Runtime::new().unwrap();
+ let mut rt = rt();
rt.block_on(async move {
let registry = Registry::new(vec![
EventInfo::default(),
@@ -307,4 +307,8 @@ mod tests {
drop(second_rx);
}
+
+ fn rt() -> Runtime {
+ runtime::Builder::new().current_thread().build().unwrap()
+ }
}
diff --git a/tokio/src/signal/windows.rs b/tokio/src/signal/windows.rs
index 1e68d628..96e585ba 100644
--- a/tokio/src/signal/windows.rs
+++ b/tokio/src/signal/windows.rs
@@ -174,13 +174,13 @@ impl Stream for CtrlBreak {
#[cfg(all(test, not(loom)))]
mod tests {
use super::*;
- use crate::runtime::current_thread::Runtime;
+ use crate::runtime::Runtime;
use futures_util::stream::StreamExt;
#[test]
fn ctrl_c() {
- let mut rt = Runtime::new().unwrap();
+ let mut rt = rt();
rt.block_on(async {
let ctrl_c = crate::signal::ctrl_c().expect("failed to create CtrlC");
@@ -198,7 +198,7 @@ mod tests {
#[test]
fn ctrl_break() {
- let mut rt = Runtime::new().unwrap();
+ let mut rt = rt();
rt.block_on(async {
let ctrl_break = super::ctrl_break().expect("failed to create CtrlC");
@@ -213,4 +213,11 @@ mod tests {
let _ = ctrl_break.into_future().await;
});
}
+
+ fn rt() -> Runtime {
+ crate::runtime::Builder::new()
+ .current_thread()
+ .build()
+ .unwrap()
+ }
}