mirror of https://github.com/fafhrd91/actix-net
fix misplaced import.relax lifetime bound for actix-rt
This commit is contained in:
parent
9b5400aa27
commit
05d8551066
|
@ -8,7 +8,8 @@
|
|||
|
||||
### Changed
|
||||
* update tokio to 0.3
|
||||
* Remove `'static` lifetime requirement for `Runtime::block_on`. The method would accept a &Self when calling.
|
||||
* Remove `'static` lifetime requirement for `Runtime::block_on` and `SystemRunner::block_on`. These methods would accept a &Self when calling.
|
||||
* Remove `'static` lifetime requirement for `System::run`
|
||||
|
||||
## [1.1.1] - 2020-04-30
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ impl Builder {
|
|||
/// Function `f` get called within tokio runtime context.
|
||||
pub fn run<F>(self, f: F) -> io::Result<()>
|
||||
where
|
||||
F: FnOnce() + 'static,
|
||||
F: FnOnce(),
|
||||
{
|
||||
self.create_runtime(f).run()
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ impl Builder {
|
|||
|
||||
fn create_runtime<F>(self, f: F) -> SystemRunner
|
||||
where
|
||||
F: FnOnce() + 'static,
|
||||
F: FnOnce(),
|
||||
{
|
||||
let (stop_tx, stop) = channel();
|
||||
let (sys_sender, sys_receiver) = unbounded();
|
||||
|
@ -179,9 +179,9 @@ impl SystemRunner {
|
|||
}
|
||||
|
||||
/// Execute a future and wait for result.
|
||||
pub fn block_on<F, O>(&mut self, fut: F) -> O
|
||||
pub fn block_on<F, O>(&self, fut: F) -> O
|
||||
where
|
||||
F: Future<Output = O> + 'static,
|
||||
F: Future<Output = O>,
|
||||
{
|
||||
Arbiter::run_system(Some(&self.rt));
|
||||
let res = self.rt.block_on(fut);
|
||||
|
|
|
@ -256,7 +256,7 @@ impl System {
|
|||
/// Function `f` get called within tokio runtime context.
|
||||
pub fn run<F>(f: F) -> io::Result<()>
|
||||
where
|
||||
F: FnOnce() + 'static,
|
||||
F: FnOnce(),
|
||||
{
|
||||
Self::builder().run(f)
|
||||
}
|
||||
|
|
|
@ -112,3 +112,28 @@ fn join_current_arbiter() {
|
|||
"local_join should await only for the already spawned futures"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn non_static_block_on() {
|
||||
let string = String::from("test_str");
|
||||
let str = string.as_str();
|
||||
|
||||
let sys = actix_rt::System::new("borrow some");
|
||||
|
||||
sys.block_on(async {
|
||||
actix_rt::time::sleep(Duration::from_millis(1)).await;
|
||||
assert_eq!("test_str", str);
|
||||
});
|
||||
|
||||
let rt = actix_rt::Runtime::new().unwrap();
|
||||
|
||||
rt.block_on(async {
|
||||
actix_rt::time::sleep(Duration::from_millis(1)).await;
|
||||
assert_eq!("test_str", str);
|
||||
});
|
||||
|
||||
actix_rt::System::run(|| {
|
||||
assert_eq!("test_str", str);
|
||||
actix_rt::System::current().stop();
|
||||
} ).unwrap();
|
||||
}
|
|
@ -42,7 +42,6 @@ impl Signals {
|
|||
#[cfg(unix)]
|
||||
{
|
||||
use actix_rt::signal::unix;
|
||||
use futures_util::stream::Stream;
|
||||
|
||||
let mut streams = Vec::new();
|
||||
|
||||
|
@ -86,6 +85,8 @@ impl Future for Signals {
|
|||
}
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use futures_util::stream::Stream;
|
||||
|
||||
for idx in 0..self.streams.len() {
|
||||
loop {
|
||||
match Pin::new(&mut self.streams[idx].1).poll_next(cx) {
|
||||
|
|
Loading…
Reference in New Issue