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