diff options
| author | Grant Miller <[email protected]> | 2024-02-14 16:59:43 -0600 |
|---|---|---|
| committer | Grant Miller <[email protected]> | 2024-02-14 16:59:43 -0600 |
| commit | dd549dad1a93be4a71fd65ebb220e9cab4d1d70d (patch) | |
| tree | d0e00b9e328e008954ced263c6e46e255ee74bca /embassy-executor-macros | |
| parent | 5a6384333f9bbd61565f820097bb89f9fbcce282 (diff) | |
Improve hygiene
Diffstat (limited to 'embassy-executor-macros')
| -rw-r--r-- | embassy-executor-macros/src/macros/task.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/embassy-executor-macros/src/macros/task.rs b/embassy-executor-macros/src/macros/task.rs index 82579cbbe..548fa4629 100644 --- a/embassy-executor-macros/src/macros/task.rs +++ b/embassy-executor-macros/src/macros/task.rs | |||
| @@ -93,13 +93,12 @@ pub fn run(args: &[NestedMeta], f: syn::ItemFn) -> Result<TokenStream, TokenStre | |||
| 93 | #[cfg(feature = "nightly")] | 93 | #[cfg(feature = "nightly")] |
| 94 | let mut task_outer: ItemFn = parse_quote! { | 94 | let mut task_outer: ItemFn = parse_quote! { |
| 95 | #visibility fn #task_ident(#fargs) -> ::embassy_executor::SpawnToken<impl Sized> { | 95 | #visibility fn #task_ident(#fargs) -> ::embassy_executor::SpawnToken<impl Sized> { |
| 96 | trait Task { | 96 | trait _EmbassyInternalTaskTrait { |
| 97 | type Fut: core::future::Future + 'static; | 97 | type Fut: ::core::future::Future + 'static; |
| 98 | fn construct(#fargs) -> Self::Fut; | 98 | fn construct(#fargs) -> Self::Fut; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | struct ThisTask; | 101 | impl _EmbassyInternalTaskTrait for () { |
| 102 | impl Task for ThisTask { | ||
| 103 | type Fut = impl core::future::Future + 'static; | 102 | type Fut = impl core::future::Future + 'static; |
| 104 | fn construct(#fargs) -> Self::Fut { | 103 | fn construct(#fargs) -> Self::Fut { |
| 105 | #task_inner_ident(#(#full_args,)*) | 104 | #task_inner_ident(#(#full_args,)*) |
| @@ -107,7 +106,7 @@ pub fn run(args: &[NestedMeta], f: syn::ItemFn) -> Result<TokenStream, TokenStre | |||
| 107 | } | 106 | } |
| 108 | 107 | ||
| 109 | const POOL_SIZE: usize = #pool_size; | 108 | const POOL_SIZE: usize = #pool_size; |
| 110 | static POOL: ::embassy_executor::raw::TaskPool<<ThisTask as Task>::Fut, POOL_SIZE> = ::embassy_executor::raw::TaskPool::new(); | 109 | static POOL: ::embassy_executor::raw::TaskPool<<() as _EmbassyInternalTaskTrait>::Fut, POOL_SIZE> = ::embassy_executor::raw::TaskPool::new(); |
| 111 | unsafe { POOL._spawn_async_fn(move || ThisTask::construct(#(#full_args,)*)) } | 110 | unsafe { POOL._spawn_async_fn(move || ThisTask::construct(#(#full_args,)*)) } |
| 112 | } | 111 | } |
| 113 | }; | 112 | }; |
