diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-04-10 00:15:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-10 00:15:17 +0200 |
commit | be71885628c3820cc4e62d229326de16a6830fec (patch) | |
tree | 664bac497658757a77b3d96cc71a1155613b20b1 /cli/worker.rs | |
parent | ac215a24613636b6e84b37a86dc4711dfaa4f2cc (diff) |
implement Worker.terminate() and self.close() (#4684)
Diffstat (limited to 'cli/worker.rs')
-rw-r--r-- | cli/worker.rs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/cli/worker.rs b/cli/worker.rs index 9e1a646d5..c2a1ecc57 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -11,8 +11,6 @@ use deno_core::ModuleSpecifier; use deno_core::StartupData; use futures::channel::mpsc; use futures::future::FutureExt; -use futures::future::TryFutureExt; -use futures::sink::SinkExt; use futures::stream::StreamExt; use futures::task::AtomicWaker; use std::env; @@ -32,6 +30,7 @@ use url::Url; pub enum WorkerEvent { Message(Buf), Error(ErrBox), + TerminalError(ErrBox), } pub struct WorkerChannelsInternal { @@ -43,18 +42,13 @@ pub struct WorkerChannelsInternal { pub struct WorkerHandle { pub sender: mpsc::Sender<Buf>, pub receiver: Arc<AsyncMutex<mpsc::Receiver<WorkerEvent>>>, - // terminate_channel } impl WorkerHandle { - pub fn terminate(&self) { - todo!() - } - /// Post message to worker as a host. - pub async fn post_message(&self, buf: Buf) -> Result<(), ErrBox> { + pub fn post_message(&self, buf: Buf) -> Result<(), ErrBox> { let mut sender = self.sender.clone(); - sender.send(buf).map_err(ErrBox::from).await + sender.try_send(buf).map_err(ErrBox::from) } // TODO: should use `try_lock` and return error if @@ -205,6 +199,7 @@ impl Future for Worker { fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { let inner = self.get_mut(); + if let Some(deno_inspector) = inner.inspector.as_mut() { // We always poll the inspector if it exists. let _ = deno_inspector.poll_unpin(cx); @@ -249,7 +244,6 @@ impl MainWorker { ops::timers::init(isolate, &state); ops::tty::init(isolate, &state); ops::worker_host::init(isolate, &state); - ops::web_worker::init(isolate, &state, &worker.internal_channels.sender); } Self(worker) } |