sleep

Function sleep 

Source
pub fn sleep(duration_ms: SleepDuration, mode: SleepMode) -> Status
Expand description

Sleep for a given amount of time

§Usage

Allows to preempt and release the current job from the scheduler queue for a given amount of time.

The requested sleeping method support multiple modes, based on the SleepMode

  • deep sleeping — Ensure that the task is sleeping for a minimum amount of time, whatever happen.

  • shallow sleeping — sleeps for a maximum duration, allowing job schedule if an external event targets the task.

The sleep duration is based on the duration_ms input parameter. See SleepDuration definition for various duration definitions.

This syscall never fails, but may return different Status code depending on the awakening event. If the job is awoken before the end of the required sleep duration, the returned status is Status::Intr. If the job reaches the end of its sleeping duration, the syscall returns Status::Timeout.

§Example

match sentry_uapi::syscall::sleep(SleepMode::Deep, D5ms) {
   Status::Intr => (),
   Status::Timeout => (),
}