Crate sleep

source ·
Expand description

Provides APIs for tasks to sleep for specified time durations.

Key functions:

  • The sleep function delays the current task for a given number of ticks.
  • The sleep_until function delays the current task until a specific moment in the future.
  • The sleep_periodic function allows for tasks to be delayed for periodic intervals of time and can be used to implement a period task.

TODO: use regular time-keeping abstractions like Duration and Instant.

Functions

Returns the current time in ticks
Update the current tick count Used as a callback in the systick handler
Blocks the current task by putting it to sleep for duration ticks.
Blocks the current task for a fixed time period, which starts from the given last_resume_time.
Blocks the current task by putting it to sleep until a specific tick count is reached, given by resume_time.
Remove all tasks that have been delayed but are able to be unblocked now, the current tick count is provided by the system’s interrupt tick count.