mirror of https://github.com/fafhrd91/actix-net
fix spawn usages in server
This commit is contained in:
parent
7f9bf16f3e
commit
bb708cdfea
|
@ -401,7 +401,7 @@ impl Accept {
|
||||||
|
|
||||||
// after the sleep a Timer interest is sent to Accept Poll
|
// after the sleep a Timer interest is sent to Accept Poll
|
||||||
let waker = self.waker.clone();
|
let waker = self.waker.clone();
|
||||||
System::current().arbiter().send(Box::pin(async move {
|
System::current().arbiter().spawn(Box::pin(async move {
|
||||||
sleep_until(Instant::now() + Duration::from_millis(510)).await;
|
sleep_until(Instant::now() + Duration::from_millis(510)).await;
|
||||||
waker.wake(WakerInterest::Timer);
|
waker.wake(WakerInterest::Timer);
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::{io, mem};
|
||||||
|
|
||||||
use actix_rt::net::TcpStream;
|
use actix_rt::net::TcpStream;
|
||||||
use actix_rt::time::{sleep_until, Instant};
|
use actix_rt::time::{sleep_until, Instant};
|
||||||
use actix_rt::{spawn, System};
|
use actix_rt::{self as rt, System};
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver};
|
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver};
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
|
@ -288,7 +288,7 @@ impl ServerBuilder {
|
||||||
|
|
||||||
// start http server actor
|
// start http server actor
|
||||||
let server = self.server.clone();
|
let server = self.server.clone();
|
||||||
spawn(self);
|
rt::spawn(self);
|
||||||
server
|
server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,7 +364,7 @@ impl ServerBuilder {
|
||||||
|
|
||||||
let fut = join_all(iter);
|
let fut = join_all(iter);
|
||||||
|
|
||||||
spawn(async move {
|
rt::spawn(async move {
|
||||||
let _ = fut.await;
|
let _ = fut.await;
|
||||||
if let Some(tx) = completion {
|
if let Some(tx) = completion {
|
||||||
let _ = tx.send(());
|
let _ = tx.send(());
|
||||||
|
@ -373,16 +373,16 @@ impl ServerBuilder {
|
||||||
let _ = tx.send(());
|
let _ = tx.send(());
|
||||||
}
|
}
|
||||||
if exit {
|
if exit {
|
||||||
spawn(async {
|
rt::spawn(async {
|
||||||
sleep_until(Instant::now() + Duration::from_millis(300)).await;
|
sleep_until(Instant::now() + Duration::from_millis(300)).await;
|
||||||
System::current().stop();
|
System::current().stop();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
// we need to stop system if server was spawned
|
// we need to stop system if server was spawned
|
||||||
if self.exit {
|
if self.exit {
|
||||||
spawn(async {
|
rt::spawn(async {
|
||||||
sleep_until(Instant::now() + Duration::from_millis(300)).await;
|
sleep_until(Instant::now() + Duration::from_millis(300)).await;
|
||||||
System::current().stop();
|
System::current().stop();
|
||||||
});
|
});
|
||||||
|
|
|
@ -172,7 +172,7 @@ impl Worker {
|
||||||
let avail = availability.clone();
|
let avail = availability.clone();
|
||||||
|
|
||||||
// every worker runs in it's own arbiter.
|
// every worker runs in it's own arbiter.
|
||||||
Arbiter::new().send(Box::pin(async move {
|
Arbiter::new().spawn(Box::pin(async move {
|
||||||
availability.set(false);
|
availability.set(false);
|
||||||
let mut wrk = MAX_CONNS_COUNTER.with(move |conns| Worker {
|
let mut wrk = MAX_CONNS_COUNTER.with(move |conns| Worker {
|
||||||
rx,
|
rx,
|
||||||
|
|
Loading…
Reference in New Issue