Skip to content

Commit

Permalink
Merge pull request #458 from vlad9486/v7.0.1-fork
Browse files Browse the repository at this point in the history
Allow some optimization
  • Loading branch information
temeddix authored Oct 3, 2024
2 parents 986fee3 + 6c7510d commit ce3b8ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions rust_crate/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ impl<T> SignalSender<T> {
impl<T> SignalReceiver<T> {
/// Asynchronously receives the next message from the queue. Only the active
/// receiver is allowed to receive messages. If there are no messages in the
/// queue, the receiver will wait until a new message is sent. If this receiver
/// is not active, it will return `None`.
pub async fn recv(&self) -> Option<T> {
/// queue, the receiver will wait until a new message is sent.
/// If this receiver is not active, the future will return `None`.
pub fn recv(&self) -> impl Future<Output = Option<T>> {
RecvFuture {
inner: self.inner.clone(),
receiver_id: self.id, // Pass the receiver's ID to the future
}
.await
}
}

Expand Down
4 changes: 2 additions & 2 deletions rust_crate/src/shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ pub struct ShutdownEvents {
/// Awaiting this receiver in the async main Rust function
/// is necessary to prevent the async runtime in Rust from
/// finishing immediately.
pub async fn dart_shutdown() {
SHUTDOWN_EVENTS.dart_stopped.wait_async().await;
pub fn dart_shutdown() -> impl Future<Output = ()> {
SHUTDOWN_EVENTS.dart_stopped.wait_async()
}

/// Synchronization primitive that allows
Expand Down

0 comments on commit ce3b8ae

Please sign in to comment.