diff options
author | 2023-01-10 21:03:10 +0100 | |
---|---|---|
committer | 2023-03-01 00:33:30 +0100 | |
commit | d6d58b0eb88242cf63724e1420bd29f8a4489916 (patch) | |
tree | d797b67b381947cc375d9c89cdc15d0cc98dee1a /macros/src/codegen/module.rs | |
parent | cd790a94286cdc307d399b7f7a43e305e90de5bf (diff) | |
download | rtic-d6d58b0eb88242cf63724e1420bd29f8a4489916.tar.gz rtic-d6d58b0eb88242cf63724e1420bd29f8a4489916.tar.zst rtic-d6d58b0eb88242cf63724e1420bd29f8a4489916.zip |
Async tasks can now take arguments at spawn again
Diffstat (limited to 'macros/src/codegen/module.rs')
-rw-r--r-- | macros/src/codegen/module.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index 19cf2417..666bd042 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -146,6 +146,8 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 { }; let internal_spawn_ident = util::internal_task_ident(name, "spawn"); + let (input_args, input_tupled, input_untupled, input_ty) = + util::regroup_inputs(&spawnee.inputs); // Spawn caller items.push(quote!( @@ -153,17 +155,18 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 { /// Spawns the task directly #[allow(non_snake_case)] #[doc(hidden)] - pub fn #internal_spawn_ident() -> Result<(), ()> { + pub fn #internal_spawn_ident(#(#input_args,)*) -> Result<(), #input_ty> { if #exec_name.try_reserve() { + // This unsafe is protected by `try_reserve`, see its documentation for details unsafe { - // TODO: Add args here - #exec_name.spawn_unchecked(#name(#name::Context::new())); + #exec_name.spawn_unchecked(#name(#name::Context::new() #(,#input_untupled)*)); } + #pend_interrupt Ok(()) } else { - Err(()) + Err(#input_tupled) } } )); |