Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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
39 changes: 23 additions & 16 deletions node/orchestra/examples/solo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,31 @@ impl<Context> Fortified {
}
}

fn main() {
use futures::{executor, pin_mut};
async fn setup() {
let builder = Solo::builder();

let builder = builder.goblin_tower(Fortified::default());

executor::block_on(async move {
let (orchestra, _handle): (Solo<_>, _) = Solo::builder()
.goblin_tower(Fortified::default())
.spawner(DummySpawner)
.build()
.unwrap();
let builder = builder.spawner(DummySpawner);
let (orchestra, _handle): (Solo<_>, _) = builder.build().unwrap();

let orchestra_fut = orchestra
.running_subsystems
.into_future()
.timeout(std::time::Duration::from_millis(300))
.fuse();
let orchestra_fut = orchestra
.running_subsystems
.into_future()
.timeout(std::time::Duration::from_millis(300))
.fuse();

pin_mut!(orchestra_fut);
pin_mut!(orchestra_fut);

orchestra_fut.await;
}

fn assert_t_impl_trait_send<T: Send>(_: &T) {}

fn main() {
use futures::{executor, pin_mut};

orchestra_fut.await
});
let x = setup();
assert_t_impl_trait_send(&x);
executor::block_on(x);
}
6 changes: 3 additions & 3 deletions node/orchestra/proc-macro/src/impl_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub(crate) fn impl_builder(info: &OrchestraInfo) -> proc_macro2::TokenStream {
pub fn #field_name_with<'a, F>(self, subsystem_init_fn: F ) ->
#builder <InitStateSpawner, #( #post_setter_state_generics, )* #( #baggage_passthrough_state_generics, )*>
where
F: 'static + FnOnce(#handle) ->
F: 'static + Send + FnOnce(#handle) ->
::std::result::Result<#field_type, #error_ty>,
{
let boxed_func = Init::<#field_type>::Fn(
Expand Down Expand Up @@ -206,7 +206,7 @@ pub(crate) fn impl_builder(info: &OrchestraInfo) -> proc_macro2::TokenStream {
-> #builder <InitStateSpawner, #( #post_replace_state_generics, )* #( #baggage_passthrough_state_generics, )*>
where
#field_type: 'static,
F: 'static + FnOnce(#field_type) -> NEW,
F: 'static + Send + FnOnce(#field_type) -> NEW,
NEW: #support_crate ::Subsystem<#subsystem_ctx_name< #subsystem_consumes >, #error_ty>,
{
let replacement: Init<NEW> = match self.#field_name {
Expand Down Expand Up @@ -333,7 +333,7 @@ pub(crate) fn impl_builder(info: &OrchestraInfo) -> proc_macro2::TokenStream {

let mut ts = quote! {
/// Convenience alias.
type SubsystemInitFn<T> = Box<dyn FnOnce(#handle) -> ::std::result::Result<T, #error_ty> >;
type SubsystemInitFn<T> = Box<dyn FnOnce(#handle) -> ::std::result::Result<T, #error_ty> + Send + 'static>;

/// Type for the initialized field of the orchestra builder
pub enum Init<T> {
Expand Down