mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 00:02:28 +00:00
Merge pull request #2574 from GrantM11235/atpit
Use ATPIT for task macro
This commit is contained in:
commit
6eb539a6a1
@ -93,10 +93,21 @@ pub fn run(args: &[NestedMeta], f: syn::ItemFn) -> Result<TokenStream, TokenStre
|
|||||||
#[cfg(feature = "nightly")]
|
#[cfg(feature = "nightly")]
|
||||||
let mut task_outer: ItemFn = parse_quote! {
|
let mut task_outer: ItemFn = parse_quote! {
|
||||||
#visibility fn #task_ident(#fargs) -> ::embassy_executor::SpawnToken<impl Sized> {
|
#visibility fn #task_ident(#fargs) -> ::embassy_executor::SpawnToken<impl Sized> {
|
||||||
type Fut = impl ::core::future::Future + 'static;
|
trait _EmbassyInternalTaskTrait {
|
||||||
|
type Fut: ::core::future::Future + 'static;
|
||||||
|
fn construct(#fargs) -> Self::Fut;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl _EmbassyInternalTaskTrait for () {
|
||||||
|
type Fut = impl core::future::Future + 'static;
|
||||||
|
fn construct(#fargs) -> Self::Fut {
|
||||||
|
#task_inner_ident(#(#full_args,)*)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const POOL_SIZE: usize = #pool_size;
|
const POOL_SIZE: usize = #pool_size;
|
||||||
static POOL: ::embassy_executor::raw::TaskPool<Fut, POOL_SIZE> = ::embassy_executor::raw::TaskPool::new();
|
static POOL: ::embassy_executor::raw::TaskPool<<() as _EmbassyInternalTaskTrait>::Fut, POOL_SIZE> = ::embassy_executor::raw::TaskPool::new();
|
||||||
unsafe { POOL._spawn_async_fn(move || #task_inner_ident(#(#full_args,)*)) }
|
unsafe { POOL._spawn_async_fn(move || <() as _EmbassyInternalTaskTrait>::construct(#(#full_args,)*)) }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#[cfg(not(feature = "nightly"))]
|
#[cfg(not(feature = "nightly"))]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#![cfg_attr(feature = "nightly", feature(type_alias_impl_trait))]
|
#![cfg_attr(feature = "nightly", feature(impl_trait_in_assoc_type))]
|
||||||
|
|
||||||
use std::boxed::Box;
|
use std::boxed::Box;
|
||||||
use std::future::poll_fn;
|
use std::future::poll_fn;
|
||||||
|
Loading…
Reference in New Issue
Block a user