Move macro helper functions to embassy-executor

This commit is contained in:
Matthew Tran
2025-03-29 02:45:48 -05:00
parent 35b353ab94
commit 034e9fc218
2 changed files with 29 additions and 32 deletions

View File

@@ -59,6 +59,8 @@ pub mod _export {
use core::future::Future;
use core::mem::MaybeUninit;
use crate::raw::TaskPool;
pub trait TaskFn<Args>: Copy {
type Fut: Future + 'static;
}
@@ -116,6 +118,30 @@ pub mod _export {
}
}
pub const fn task_pool_size<F, Args, Fut, const POOL_SIZE: usize>(_: F) -> usize
where
F: TaskFn<Args, Fut = Fut>,
Fut: Future + 'static,
{
size_of::<TaskPool<Fut, POOL_SIZE>>()
}
pub const fn task_pool_align<F, Args, Fut, const POOL_SIZE: usize>(_: F) -> usize
where
F: TaskFn<Args, Fut = Fut>,
Fut: Future + 'static,
{
align_of::<TaskPool<Fut, POOL_SIZE>>()
}
pub const fn task_pool_new<F, Args, Fut, const POOL_SIZE: usize>(_: F) -> TaskPool<Fut, POOL_SIZE>
where
F: TaskFn<Args, Fut = Fut>,
Fut: Future + 'static,
{
TaskPool::new()
}
#[allow(private_bounds)]
#[repr(transparent)]
pub struct Align<const N: usize>([<Self as Alignment>::Archetype; 0])