diff options
author | 2023-01-09 21:02:53 +0100 | |
---|---|---|
committer | 2023-03-01 00:33:29 +0100 | |
commit | cd790a94286cdc307d399b7f7a43e305e90de5bf (patch) | |
tree | 5a83dd0739c90fb848744c22bcbe689eed1f1fcf /macros/src/codegen/module.rs | |
parent | 1eabb94f0424d7ff85786ad05615da69a379f01d (diff) | |
download | rtic-cd790a94286cdc307d399b7f7a43e305e90de5bf.tar.gz rtic-cd790a94286cdc307d399b7f7a43e305e90de5bf.tar.zst rtic-cd790a94286cdc307d399b7f7a43e305e90de5bf.zip |
More work on new spawn/executor
Diffstat (limited to 'macros/src/codegen/module.rs')
-rw-r--r-- | macros/src/codegen/module.rs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index 70fbb5e6..19cf2417 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -98,6 +98,7 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 { }; let internal_context_name = util::internal_task_ident(name, "Context"); + let exec_name = util::internal_task_ident(name, "EXEC"); items.push(quote!( #(#cfgs)* @@ -147,25 +148,25 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 { let internal_spawn_ident = util::internal_task_ident(name, "spawn"); // Spawn caller - let rq = util::rq_async_ident(name); items.push(quote!( - - #(#cfgs)* - /// Spawns the task directly - #[allow(non_snake_case)] - #[doc(hidden)] - pub fn #internal_spawn_ident() -> Result<(), ()> { - unsafe { - // TODO: Fix this to be compare and swap - if #rq.load(core::sync::atomic::Ordering::Acquire) { - Err(()) - } else { - #rq.store(true, core::sync::atomic::Ordering::Release); + #(#cfgs)* + /// Spawns the task directly + #[allow(non_snake_case)] + #[doc(hidden)] + pub fn #internal_spawn_ident() -> Result<(), ()> { + if #exec_name.try_reserve() { + unsafe { + // TODO: Add args here + #exec_name.spawn_unchecked(#name(#name::Context::new())); + } #pend_interrupt + Ok(()) + } else { + Err(()) } } - })); + )); module_items.push(quote!( #(#cfgs)* |