mirror of https://github.com/fafhrd91/actix-net
remove printlns
This commit is contained in:
parent
ce627bf932
commit
c6543ed52f
|
@ -29,11 +29,6 @@ pub struct System {
|
||||||
worker_handle: WorkerHandle,
|
worker_handle: WorkerHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for System {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
eprintln!("dropping System")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl System {
|
impl System {
|
||||||
/// Create a new system.
|
/// Create a new system.
|
||||||
|
@ -42,7 +37,6 @@ impl System {
|
||||||
/// Panics if underlying Tokio runtime can not be created.
|
/// Panics if underlying Tokio runtime can not be created.
|
||||||
#[allow(clippy::new_ret_no_self)]
|
#[allow(clippy::new_ret_no_self)]
|
||||||
pub fn new() -> SystemRunner {
|
pub fn new() -> SystemRunner {
|
||||||
eprintln!("System::new");
|
|
||||||
Self::create_runtime(async {})
|
Self::create_runtime(async {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,21 +71,16 @@ impl System {
|
||||||
let (stop_tx, stop_rx) = oneshot::channel();
|
let (stop_tx, stop_rx) = oneshot::channel();
|
||||||
let (sys_tx, sys_rx) = mpsc::unbounded_channel();
|
let (sys_tx, sys_rx) = mpsc::unbounded_channel();
|
||||||
|
|
||||||
eprintln!("creating runtime");
|
|
||||||
let rt = Runtime::new().expect("Actix (Tokio) runtime could not be created.");
|
let rt = Runtime::new().expect("Actix (Tokio) runtime could not be created.");
|
||||||
eprintln!("creating worker and system");
|
|
||||||
let system = System::construct(sys_tx, Worker::new_current_thread(rt.local_set()));
|
let system = System::construct(sys_tx, Worker::new_current_thread(rt.local_set()));
|
||||||
|
|
||||||
eprintln!("creating system controller");
|
|
||||||
// init background system worker
|
// init background system worker
|
||||||
let sys_worker = SystemController::new(sys_rx, stop_tx);
|
let sys_worker = SystemController::new(sys_rx, stop_tx);
|
||||||
rt.spawn(sys_worker);
|
rt.spawn(sys_worker);
|
||||||
|
|
||||||
eprintln!("running init future");
|
|
||||||
// run system init future
|
// run system init future
|
||||||
rt.block_on(init_fut);
|
rt.block_on(init_fut);
|
||||||
|
|
||||||
eprintln!("done; here's your system runner");
|
|
||||||
SystemRunner {
|
SystemRunner {
|
||||||
rt,
|
rt,
|
||||||
stop_rx,
|
stop_rx,
|
||||||
|
@ -104,7 +93,6 @@ impl System {
|
||||||
/// # Panics
|
/// # Panics
|
||||||
/// Panics if no system is registered on the current thread.
|
/// Panics if no system is registered on the current thread.
|
||||||
pub fn current() -> System {
|
pub fn current() -> System {
|
||||||
eprintln!("gib current system");
|
|
||||||
CURRENT.with(|cell| match *cell.borrow() {
|
CURRENT.with(|cell| match *cell.borrow() {
|
||||||
Some(ref sys) => sys.clone(),
|
Some(ref sys) => sys.clone(),
|
||||||
None => panic!("System is not running"),
|
None => panic!("System is not running"),
|
||||||
|
@ -163,7 +151,6 @@ pub struct SystemRunner {
|
||||||
impl SystemRunner {
|
impl SystemRunner {
|
||||||
/// Starts event loop and will return once [System] is [stopped](System::stop).
|
/// Starts event loop and will return once [System] is [stopped](System::stop).
|
||||||
pub fn run(self) -> io::Result<()> {
|
pub fn run(self) -> io::Result<()> {
|
||||||
eprintln!("SystemRunner: run");
|
|
||||||
|
|
||||||
let SystemRunner { rt, stop_rx, .. } = self;
|
let SystemRunner { rt, stop_rx, .. } = self;
|
||||||
|
|
||||||
|
@ -219,11 +206,6 @@ impl SystemController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Drop for SystemController {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
eprintln!("dropping SystemController")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Future for SystemController {
|
impl Future for SystemController {
|
||||||
type Output = ();
|
type Output = ();
|
||||||
|
|
|
@ -45,15 +45,9 @@ pub struct WorkerHandle {
|
||||||
sender: mpsc::UnboundedSender<WorkerCommand>,
|
sender: mpsc::UnboundedSender<WorkerCommand>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for WorkerHandle {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
eprintln!("dropping WorkerHandle")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WorkerHandle {
|
impl WorkerHandle {
|
||||||
pub(crate) fn new(sender: mpsc::UnboundedSender<WorkerCommand>) -> Self {
|
pub(crate) fn new(sender: mpsc::UnboundedSender<WorkerCommand>) -> Self {
|
||||||
eprintln!("WorkerHandle::new");
|
|
||||||
Self { sender }
|
Self { sender }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,21 +266,14 @@ struct WorkerRunner {
|
||||||
rx: mpsc::UnboundedReceiver<WorkerCommand>,
|
rx: mpsc::UnboundedReceiver<WorkerCommand>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for WorkerRunner {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
eprintln!("dropping WorkerRunner")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Future for WorkerRunner {
|
impl Future for WorkerRunner {
|
||||||
type Output = ();
|
type Output = ();
|
||||||
|
|
||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
eprintln!("WorkerRunner: poll");
|
|
||||||
|
|
||||||
// process all items currently buffered in channel
|
// process all items currently buffered in channel
|
||||||
loop {
|
loop {
|
||||||
eprintln!("WorkerRunner: loop");
|
|
||||||
|
|
||||||
match ready!(Pin::new(&mut self.rx).poll_recv(cx)) {
|
match ready!(Pin::new(&mut self.rx).poll_recv(cx)) {
|
||||||
// channel closed; no more messages can be received
|
// channel closed; no more messages can be received
|
||||||
|
@ -295,11 +282,9 @@ impl Future for WorkerRunner {
|
||||||
// process worker command
|
// process worker command
|
||||||
Some(item) => match item {
|
Some(item) => match item {
|
||||||
WorkerCommand::Stop => {
|
WorkerCommand::Stop => {
|
||||||
eprintln!("WorkerRunner: stopping");
|
|
||||||
return Poll::Ready(());
|
return Poll::Ready(());
|
||||||
}
|
}
|
||||||
WorkerCommand::Execute(task_fut) => {
|
WorkerCommand::Execute(task_fut) => {
|
||||||
eprintln!("WorkerRunner: executing task");
|
|
||||||
tokio::task::spawn_local(task_fut);
|
tokio::task::spawn_local(task_fut);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -192,10 +192,7 @@ fn no_system_worker_new_panic() {
|
||||||
fn system_worker_spawn() {
|
fn system_worker_spawn() {
|
||||||
let runner = System::new();
|
let runner = System::new();
|
||||||
|
|
||||||
eprintln!("making channel");
|
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
|
|
||||||
eprintln!("getting initial system worker");
|
|
||||||
let sys = System::current();
|
let sys = System::current();
|
||||||
|
|
||||||
thread::spawn(|| {
|
thread::spawn(|| {
|
||||||
|
@ -212,10 +209,7 @@ fn system_worker_spawn() {
|
||||||
|
|
||||||
let wrk = sys.worker();
|
let wrk = sys.worker();
|
||||||
wrk.spawn(async move {
|
wrk.spawn(async move {
|
||||||
eprintln!("before send");
|
|
||||||
tx.send(42u32).unwrap();
|
tx.send(42u32).unwrap();
|
||||||
|
|
||||||
eprintln!("after send");
|
|
||||||
System::current().stop();
|
System::current().stop();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue