#[repr(transparent)]pub struct TaskId(pub u32);Expand description
A type-safe, zero-cost wrapper for an OSAL Task ID.
Tuple Fields§
§0: u32Implementations§
Source§impl TaskId
impl TaskId
Sourcepub fn set_priority(&self, priority: u8) -> Result<()>
pub fn set_priority(&self, priority: u8) -> Result<()>
Sourcepub fn index(&self) -> Result<u32>
pub fn index(&self) -> Result<u32>
Returns a zero-based index for this task, suitable for indexing into a user-provided per-task context array.
This is the workaround for OSAL not supporting per-task arguments (see nasa/osal#1394). Usage:
ⓘ
static CONTEXTS: [AtomicPtr<()>; 16] = /* ... */;
// At task creation:
let task = Task::new("worker", worker_entry, ...)?;
CONTEXTS[task.id().index()? as usize].store(ctx_ptr, Ordering::Release);
// Inside the task:
let idx = TaskId::current()?.index()? as usize;
let ctx = CONTEXTS[idx].load(Ordering::Acquire);Sourcepub fn current_index() -> Result<u32>
pub fn current_index() -> Result<u32>
Shorthand: get the current task’s zero-based index.
Trait Implementations§
impl Copy for TaskId
impl Eq for TaskId
impl StructuralPartialEq for TaskId
Auto Trait Implementations§
impl Freeze for TaskId
impl RefUnwindSafe for TaskId
impl Send for TaskId
impl Sync for TaskId
impl Unpin for TaskId
impl UnsafeUnpin for TaskId
impl UnwindSafe for TaskId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more