embassy-executor

Crates

git

Versions

riscv64

Flavors

Skip to main content

Trace

Trait Trace 

Source
pub trait Trace {
    // Required methods
    fn poll_start(executor: ExecutorId);
    fn task_new(executor: ExecutorId, task: TaskRef);
    fn task_end(executor: ExecutorId, task: TaskRef);
    fn task_exec_begin(executor: ExecutorId, task: TaskRef);
    fn task_exec_end(executor: ExecutorId, task: TaskRef);
    fn task_ready_begin(executor: ExecutorId, task: TaskRef);
    fn executor_idle(executor: ExecutorId);
    fn idle();
    fn task_name_set(task: TaskRef, name: &'static str);
    fn task_priority_set(task: TaskRef, priority: u8);
    fn task_deadline_set(task: TaskRef, deadline: u64);
}
Expand description

Executor trace hooks.

Implement this trait and register the implementation with the trace_impl! macro to receive callbacks on task and executor lifecycle events. All callbacks must be implemented.

See the module documentation for the task and executor tracing lifecycles.

Required Methods§

Source

fn poll_start(executor: ExecutorId)

This callback is called when the executor begins polling. This will always be paired with a later call to executor_idle.

This marks the EXECUTOR state transition from IDLE -> SCHEDULING.

Source

fn task_new(executor: ExecutorId, task: TaskRef)

This callback is called AFTER a task is initialized/allocated, and BEFORE it is enqueued to run for the first time. If the task ends (and does not loop “forever”), there will be a matching call to task_end.

Tasks start life in the SPAWNED state.

Source

fn task_end(executor: ExecutorId, task: TaskRef)

This callback is called AFTER a task is destructed/freed. This will always have a prior matching call to task_new.

Source

fn task_exec_begin(executor: ExecutorId, task: TaskRef)

This callback is called AFTER a task has been dequeued from the runqueue, and BEFORE the task is polled. There will always be a matching call to task_exec_end.

This marks the TASK state transition from WAITING -> RUNNING This marks the EXECUTOR state transition from SCHEDULING -> POLLING

Source

fn task_exec_end(executor: ExecutorId, task: TaskRef)

This callback is called AFTER a task has completed polling. There will always be a matching call to task_exec_begin.

This marks the TASK state transition from either:

This marks the EXECUTOR state transition from POLLING -> SCHEDULING

Source

fn task_ready_begin(executor: ExecutorId, task: TaskRef)

This callback is called AFTER the waker for a task is awoken, and BEFORE it is added to the run queue.

If the given task is currently RUNNING, this marks no state change, BUT the RUNNING task will then move to the WAITING stage when polling is complete.

If the given task is currently IDLE, this marks the TASK state transition from IDLE -> WAITING.

NOTE: This may be called from an interrupt, outside the context of the current task or executor.

Source

fn executor_idle(executor: ExecutorId)

This callback is called AFTER all dequeued tasks in a single call to poll have been processed. This will always be paired with a call to poll_start.

This marks the EXECUTOR state transition from SCHEDULING -> IDLE

Source

fn idle()

This callback is called right before the thread-mode executor puts the current thread/core to sleep (e.g. wfe/wfi).

Unlike executor_idle, this is never called by interrupt executors, since they return to a preempted context after polling and the system keeps running.

Note in multi-core chips, or when using threads under std or an RTOS, this doesn’t mean the entire system is idle, it only means the current core/thread is.

Source

fn task_name_set(task: TaskRef, name: &'static str)

This callback is called AFTER the name of a task is set.

This function can be called when the task is not running and it does not signal a state change.

Source

fn task_priority_set(task: TaskRef, priority: u8)

This callback is called AFTER the priority of a task is set.

This function can be called when the task is not running and it does not signal a state change.

Source

fn task_deadline_set(task: TaskRef, deadline: u64)

This callback is called AFTER the deadline of a task is set.

This function can be called when the task is not running and it does not signal a state change.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§