Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement separate signal and message flows #66

Merged
merged 6 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions orchestra/proc-macro/src/impl_subsystem_ctx_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,12 @@ pub(crate) fn impl_subsystem_context_trait_for(
}
}

async fn recv_signal(&mut self) -> ::std::result::Result<#signal, #error_ty> {
self.signals.next().await.ok_or(#support_crate ::OrchestraError::Context(
"Signal channel is terminated and empty.".to_owned(),
).into())
}

fn sender(&mut self) -> &mut Self::Sender {
&mut self.to_subsystems
}
Expand Down
5 changes: 4 additions & 1 deletion orchestra/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,12 @@ pub trait SubsystemContext: Send + 'static {
/// using `pending!()` macro you will end up with a busy loop!
async fn try_recv(&mut self) -> Result<Option<FromOrchestra<Self::Message, Self::Signal>>, ()>;

/// Receive a message.
/// Receive a signal or a message.
async fn recv(&mut self) -> Result<FromOrchestra<Self::Message, Self::Signal>, Self::Error>;

/// Receive a signal.
async fn recv_signal(&mut self) -> Result<Self::Signal, Self::Error>;
sandreim marked this conversation as resolved.
Show resolved Hide resolved

/// Spawn a child task on the executor.
fn spawn(
&mut self,
Expand Down
Loading