diff options
| author | Matthew Tran <[email protected]> | 2025-03-29 02:45:48 -0500 |
|---|---|---|
| committer | Matthew Tran <[email protected]> | 2025-03-29 03:52:00 -0500 |
| commit | 034e9fc218f1a348f451f56a5b9f3941fc046b1a (patch) | |
| tree | c7d366b388eaee60fa7f8ebb5a077bf42df20898 /embassy-executor | |
| parent | 35b353ab948256f4ae959767a7652c24bd42cd57 (diff) | |
Move macro helper functions to embassy-executor
Diffstat (limited to 'embassy-executor')
| -rw-r--r-- | embassy-executor/src/lib.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs index 5485f6a6a..d6bd63665 100644 --- a/embassy-executor/src/lib.rs +++ b/embassy-executor/src/lib.rs | |||
| @@ -59,6 +59,8 @@ pub mod _export { | |||
| 59 | use core::future::Future; | 59 | use core::future::Future; |
| 60 | use core::mem::MaybeUninit; | 60 | use core::mem::MaybeUninit; |
| 61 | 61 | ||
| 62 | use crate::raw::TaskPool; | ||
| 63 | |||
| 62 | pub trait TaskFn<Args>: Copy { | 64 | pub trait TaskFn<Args>: Copy { |
| 63 | type Fut: Future + 'static; | 65 | type Fut: Future + 'static; |
| 64 | } | 66 | } |
| @@ -116,6 +118,30 @@ pub mod _export { | |||
| 116 | } | 118 | } |
| 117 | } | 119 | } |
| 118 | 120 | ||
| 121 | pub const fn task_pool_size<F, Args, Fut, const POOL_SIZE: usize>(_: F) -> usize | ||
| 122 | where | ||
| 123 | F: TaskFn<Args, Fut = Fut>, | ||
| 124 | Fut: Future + 'static, | ||
| 125 | { | ||
| 126 | size_of::<TaskPool<Fut, POOL_SIZE>>() | ||
| 127 | } | ||
| 128 | |||
| 129 | pub const fn task_pool_align<F, Args, Fut, const POOL_SIZE: usize>(_: F) -> usize | ||
| 130 | where | ||
| 131 | F: TaskFn<Args, Fut = Fut>, | ||
| 132 | Fut: Future + 'static, | ||
| 133 | { | ||
| 134 | align_of::<TaskPool<Fut, POOL_SIZE>>() | ||
| 135 | } | ||
| 136 | |||
| 137 | pub const fn task_pool_new<F, Args, Fut, const POOL_SIZE: usize>(_: F) -> TaskPool<Fut, POOL_SIZE> | ||
| 138 | where | ||
| 139 | F: TaskFn<Args, Fut = Fut>, | ||
| 140 | Fut: Future + 'static, | ||
| 141 | { | ||
| 142 | TaskPool::new() | ||
| 143 | } | ||
| 144 | |||
| 119 | #[allow(private_bounds)] | 145 | #[allow(private_bounds)] |
| 120 | #[repr(transparent)] | 146 | #[repr(transparent)] |
| 121 | pub struct Align<const N: usize>([<Self as Alignment>::Archetype; 0]) | 147 | pub struct Align<const N: usize>([<Self as Alignment>::Archetype; 0]) |
