summaryrefslogtreecommitdiff
path: root/embassy-macros
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2022-04-27 04:45:23 +0200
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2022-04-27 04:56:41 +0200
commit1599009a4f5fe1a0f9596b7b27bfd9fd84366377 (patch)
treeacd5a0bf15ece515c576673cfcfd8a81bd8d91f9 /embassy-macros
parent6f6c16f44924de4d71d0e5e3acc0908f2dd474e6 (diff)
downloadembassy-1599009a4f5fe1a0f9596b7b27bfd9fd84366377.zip
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.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/embassy-macros/src/macros/task.rs b/embassy-macros/src/macros/task.rs
index 96932d77..e48de3d6 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
#visibility fn #task_ident(#fargs) -> #embassy_path::executor::SpawnToken<impl Sized> {
type Fut = impl ::core::future::Future + 'static;
static POOL: #embassy_path::executor::raw::TaskPool<Fut, #pool_size> = #embassy_path::executor::raw::TaskPool::new();
- POOL.spawn(move || #task_inner_ident(#(#arg_names,)*))
+ unsafe { POOL._spawn_async_fn(move || #task_inner_ident(#(#arg_names,)*)) }
}
};