Files
tokio/tokio/tests/signal_drop_rt.rs
T
Carl Lerche d70c928d88 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.
2019-11-01 13:18:52 -07:00

45 lines
999 B
Rust

#![cfg(unix)]
#![warn(rust_2018_idioms)]
mod support {
pub mod signal;
}
use support::signal::send_signal;
use tokio::prelude::*;
use tokio::runtime::Runtime;
use tokio::signal::unix::{signal, SignalKind};
#[test]
fn dropping_loops_does_not_cause_starvation() {
let kind = SignalKind::user_defined1();
let mut first_rt = rt();
let mut first_signal =
first_rt.block_on(async { signal(kind).expect("failed to register first signal") });
let mut second_rt = rt();
let mut second_signal =
second_rt.block_on(async { signal(kind).expect("failed to register second signal") });
send_signal(libc::SIGUSR1);
first_rt
.block_on(first_signal.next())
.expect("failed to await first signal");
drop(first_rt);
drop(first_signal);
send_signal(libc::SIGUSR1);
second_rt.block_on(second_signal.next());
}
fn rt() -> Runtime {
tokio::runtime::Builder::new()
.current_thread()
.build()
.unwrap()
}