]> Repositorios git - scryer-prolog.git/commitdiff
use Notify instead of Sender
authorDanil Platonov <[email protected]>
Tue, 2 Jun 2026 07:49:00 +0000 (00:49 -0700)
committerDanil Platonov <[email protected]>
Tue, 2 Jun 2026 07:49:00 +0000 (00:49 -0700)
src/http.rs
src/machine/system_calls.rs

index 939dbe7d6bb98ce5de284dd9cea730f80e27875c..d9f669d762e8eff983bc998af92122504d8c7a02 100644 (file)
@@ -1,11 +1,12 @@
 use bytes::{buf::Reader, Bytes};
 use std::sync::{Arc, Condvar, Mutex};
+use tokio::sync::Notify;
 
 use warp::http;
 
 pub struct HttpListener {
     pub incoming: std::sync::mpsc::Receiver<HttpRequest>,
-    pub warp_shutdown: tokio::sync::mpsc::Sender<()>,
+    pub warp_shutdown: Arc<Notify>,
 }
 
 pub struct HttpRequest {
index 3aba0c1789176de4e3aea543c4af67ad51f6de8d..1201e369346ae1c77f0202e06b010ffdd6e53e6b 100644 (file)
@@ -61,6 +61,7 @@ use std::str::FromStr;
 use std::sync::LazyLock;
 #[cfg(feature = "http")]
 use std::sync::{Arc, Condvar, Mutex};
+use tokio::sync::Notify;
 
 use chrono::{offset::Local, DateTime};
 #[cfg(not(target_arch = "wasm32"))]
@@ -4594,7 +4595,7 @@ impl Machine {
             let (tx, rx) = std::sync::mpsc::sync_channel(1024);
 
             // warp shutdown channel
-            let (warp_shutdown_tx, mut warp_shutdown_rx) = tokio::sync::mpsc::channel(1);
+            let warp_shutdown = Arc::new(Notify::new());
 
             let runtime = tokio::runtime::Handle::current();
             let _guard = runtime.enter();
@@ -4657,6 +4658,7 @@ impl Machine {
                     },
                 );
 
+            let warp_shutdown_clone = warp_shutdown.clone();
             runtime.spawn(async move {
                 match ssl_server {
                     Some((key, cert)) => {
@@ -4665,7 +4667,7 @@ impl Machine {
                             .key(key)
                             .cert(cert)
                             .bind_with_graceful_shutdown(addr, async move {
-                                warp_shutdown_rx.recv().await;
+                                warp_shutdown_clone.notified().await;
                             });
 
                         tokio::task::spawn(server);
@@ -4673,7 +4675,7 @@ impl Machine {
                     None => {
                         let (_addr, server) =
                             warp::serve(serve).bind_with_graceful_shutdown(addr, async move {
-                                warp_shutdown_rx.recv().await;
+                                warp_shutdown_clone.notified().await;
                             });
 
                         tokio::task::spawn(server);
@@ -4683,7 +4685,7 @@ impl Machine {
 
             let http_listener = HttpListener {
                 incoming: rx,
-                warp_shutdown: warp_shutdown_tx,
+                warp_shutdown: warp_shutdown,
             };
             let http_listener: TypedArenaPtr<HttpListener> =
                 arena_alloc!(http_listener, &mut self.machine_st.arena);
@@ -4706,7 +4708,7 @@ impl Machine {
             (HeapCellValueTag::Cons, cons_ptr) => {
                 match_untyped_arena_ptr!(cons_ptr,
                     (ArenaHeaderTag::HttpListener, http_listener) => {
-                        let _ = futures::executor::block_on(http_listener.warp_shutdown.send(()));
+                        http_listener.warp_shutdown.notify_one();
                     }
                     _ => {
                             unreachable!();