diff options
author | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2022-04-27 03:23:54 +0200 |
---|---|---|
committer | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2022-04-27 04:56:41 +0200 |
commit | 293f54d13406850d24d1226eb77989f4fa8db9f4 (patch) | |
tree | c8831ae9d2d046549b3d64294408920b9b8a5597 /embassy-macros | |
parent | df814f9bbd5cc03f4d60eb8cb19374d23f0a84a0 (diff) | |
download | embassy-293f54d13406850d24d1226eb77989f4fa8db9f4.zip |
executor: add raw::TaskPool.
This simplifies the macro code a bit.
Diffstat (limited to 'embassy-macros')
-rw-r--r-- | embassy-macros/src/macros/task.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/embassy-macros/src/macros/task.rs b/embassy-macros/src/macros/task.rs index 396ce18f..c450982c 100644 --- a/embassy-macros/src/macros/task.rs +++ b/embassy-macros/src/macros/task.rs @@ -76,14 +76,11 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke #visibility fn #task_ident(#fargs) -> #embassy_path::executor::SpawnToken<impl ::core::future::Future + 'static> { use ::core::future::Future; use #embassy_path::executor::SpawnToken; - use #embassy_path::executor::raw::TaskStorage; + use #embassy_path::executor::raw::TaskPool; type Fut = impl Future + 'static; - #[allow(clippy::declare_interior_mutable_const)] - const NEW_TS: TaskStorage<Fut> = TaskStorage::new(); - - static POOL: [TaskStorage<Fut>; #pool_size] = [NEW_TS; #pool_size]; + static POOL: TaskPool<Fut, #pool_size> = TaskPool::new(); // Opaque type laundering, to obscure its origin! // Workaround for "opaque type's hidden type cannot be another opaque type from the same scope" @@ -92,7 +89,7 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke token } - launder_tait(unsafe { TaskStorage::spawn_pool(&POOL, move || #task_inner_ident(#(#arg_names,)*)) }) + launder_tait(POOL.spawn(move || #task_inner_ident(#(#arg_names,)*))) } }; |