diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-04-27 04:45:23 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-04-27 04:56:41 +0200 |
| commit | 1599009a4f5fe1a0f9596b7b27bfd9fd84366377 (patch) | |
| tree | acd5a0bf15ece515c576673cfcfd8a81bd8d91f9 /embassy-macros | |
| parent | 6f6c16f44924de4d71d0e5e3acc0908f2dd474e6 (diff) | |
executor: "send-spawn is OK if the args are Send" only holds for async fn futures.
The normal `spawn()` methods can be called directly by the user, with arbitrary hand-implemented futures.
We can't enforce they're only called with `async fn` futures. Therefore, make these
require `F: Send`, and add a "private" one only for use in the macro, which can enforce it.
Diffstat (limited to 'embassy-macros')
| -rw-r--r-- | embassy-macros/src/macros/task.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/embassy-macros/src/macros/task.rs b/embassy-macros/src/macros/task.rs index 96932d77c..e48de3d63 100644 --- a/embassy-macros/src/macros/task.rs +++ b/embassy-macros/src/macros/task.rs | |||
| @@ -76,7 +76,7 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke | |||
| 76 | #visibility fn #task_ident(#fargs) -> #embassy_path::executor::SpawnToken<impl Sized> { | 76 | #visibility fn #task_ident(#fargs) -> #embassy_path::executor::SpawnToken<impl Sized> { |
| 77 | type Fut = impl ::core::future::Future + 'static; | 77 | type Fut = impl ::core::future::Future + 'static; |
| 78 | static POOL: #embassy_path::executor::raw::TaskPool<Fut, #pool_size> = #embassy_path::executor::raw::TaskPool::new(); | 78 | static POOL: #embassy_path::executor::raw::TaskPool<Fut, #pool_size> = #embassy_path::executor::raw::TaskPool::new(); |
| 79 | POOL.spawn(move || #task_inner_ident(#(#arg_names,)*)) | 79 | unsafe { POOL._spawn_async_fn(move || #task_inner_ident(#(#arg_names,)*)) } |
| 80 | } | 80 | } |
| 81 | }; | 81 | }; |
| 82 | 82 | ||
