diff --git a/node/orchestra/examples/solo.rs b/node/orchestra/examples/solo.rs index 67ebc292e46d..cc82656759cd 100644 --- a/node/orchestra/examples/solo.rs +++ b/node/orchestra/examples/solo.rs @@ -46,24 +46,29 @@ impl Fortified { } } -fn main() { - use futures::{executor, pin_mut}; +async fn setup() { + let builder = Solo::builder(); + + let builder = builder.goblin_tower(Fortified::default()); + + let builder = builder.spawner(DummySpawner); + let (orchestra, _handle): (Solo<_>, _) = builder.build().unwrap(); - executor::block_on(async move { - let (orchestra, _handle): (Solo<_>, _) = Solo::builder() - .goblin_tower(Fortified::default()) - .spawner(DummySpawner) - .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(); + futures::pin_mut!(orchestra_fut); - pin_mut!(orchestra_fut); + orchestra_fut.await; +} + +fn assert_t_impl_trait_send(_: &T) {} - orchestra_fut.await - }); +fn main() { + let x = setup(); + assert_t_impl_trait_send(&x); + futures::executor::block_on(x); } diff --git a/node/orchestra/proc-macro/src/impl_builder.rs b/node/orchestra/proc-macro/src/impl_builder.rs index 1be25d45b5e4..1a88dc926120 100644 --- a/node/orchestra/proc-macro/src/impl_builder.rs +++ b/node/orchestra/proc-macro/src/impl_builder.rs @@ -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 where - F: 'static + FnOnce(#handle) -> + F: 'static + Send + FnOnce(#handle) -> ::std::result::Result<#field_type, #error_ty>, { let boxed_func = Init::<#field_type>::Fn( @@ -206,7 +206,7 @@ pub(crate) fn impl_builder(info: &OrchestraInfo) -> proc_macro2::TokenStream { -> #builder 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 = match self.#field_name { @@ -333,7 +333,7 @@ pub(crate) fn impl_builder(info: &OrchestraInfo) -> proc_macro2::TokenStream { let mut ts = quote! { /// Convenience alias. - type SubsystemInitFn = Box ::std::result::Result >; + type SubsystemInitFn = Box ::std::result::Result + Send + 'static>; /// Type for the initialized field of the orchestra builder pub enum Init {