pub trait Scheduler:
Send
+ Sync
+ 'static {
// Required methods
fn enable(&self);
fn disable(&self);
fn yield_task(&self);
fn current_task(&self) -> *mut c_void;
fn task_create(
&self,
task: extern "C" fn(*mut c_void),
param: *mut c_void,
task_stack_size: usize,
) -> *mut c_void;
fn schedule_task_deletion(&self, task_handle: *mut c_void);
fn current_task_thread_semaphore(&self) -> *mut c_void;
}
Required Methods§
Sourcefn yield_task(&self)
fn yield_task(&self)
This function is called by threads and should switch to the next thread.
Sourcefn current_task(&self) -> *mut c_void
fn current_task(&self) -> *mut c_void
This function is called by threads and should return an opaque handle
for the calling thread. The same handle will be passed to
esp_wifi_preempt_schedule_task_deletion
.
Sourcefn task_create(
&self,
task: extern "C" fn(*mut c_void),
param: *mut c_void,
task_stack_size: usize,
) -> *mut c_void
fn task_create( &self, task: extern "C" fn(*mut c_void), param: *mut c_void, task_stack_size: usize, ) -> *mut c_void
This function is used to create threads. It should allocate the stack.
Sourcefn schedule_task_deletion(&self, task_handle: *mut c_void)
fn schedule_task_deletion(&self, task_handle: *mut c_void)
This function is called to let the scheduler know this thread is not needed anymore and should be deleted. After this function is called, the thread should not be scheduled anymore. The thread stack can be free’ed.
Sourcefn current_task_thread_semaphore(&self) -> *mut c_void
fn current_task_thread_semaphore(&self) -> *mut c_void
This function should return an opaque per-thread pointer to an usize-sized memory location, which will be used to store a pointer to a semaphore for this thread.