From b8b5f00e9695f46ea30af3ce63aec6dd17f356ae Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 27 Jun 2024 02:39:31 +0200 Subject: Improve async channels error handling and replace unbounded channels with bounded channels Remove all unbounded channels to prevent unbounded memory usage and potential crashes. Use `FuturesUnordered` for sending to multiple channels simultaneously. This prevents the sending loop from blocking if one channel is blocked, and helps handle errors properly. --- core/src/async_runtime/executor.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'core/src/async_runtime') diff --git a/core/src/async_runtime/executor.rs b/core/src/async_runtime/executor.rs index 9335f12..88f6370 100644 --- a/core/src/async_runtime/executor.rs +++ b/core/src/async_runtime/executor.rs @@ -25,6 +25,11 @@ impl Executor { ) -> Task { self.inner.spawn(future).into() } + + #[cfg(feature = "tokio")] + pub fn handle(&self) -> &tokio::runtime::Handle { + return self.inner.handle(); + } } static GLOBAL_EXECUTOR: OnceCell = OnceCell::new(); -- cgit v1.2.3