pub fn coarse_sleep(duration: Duration)
Expand description

Sleeps safely even with waitqueue interruptions.

This function forwards the call to the C side msleep function. As a result, duration will be rounded up to the nearest millisecond if granularity less than a millisecond is provided. Any Duration that exceeds c_uint::MAX in milliseconds is saturated.


coarse_sleep(Duration::ZERO);                   // Equivalent to `msleep(0)`.
coarse_sleep(Duration::from_nanos(1));          // Equivalent to `msleep(1)`.

coarse_sleep(Duration::from_nanos(1_000_000));  // Equivalent to `msleep(1)`.
coarse_sleep(Duration::from_nanos(1_000_001));  // Equivalent to `msleep(2)`.
coarse_sleep(Duration::from_nanos(1_999_999));  // Equivalent to `msleep(2)`.

coarse_sleep(Duration::from_millis(1));         // Equivalent to `msleep(1)`.
coarse_sleep(Duration::from_millis(2));         // Equivalent to `msleep(2)`.

coarse_sleep(Duration::from_secs(1));           // Equivalent to `msleep(1000)`.
coarse_sleep(Duration::new(1, 1));              // Equivalent to `msleep(1001)`.
coarse_sleep(Duration::new(1, 2));              // Equivalent to `msleep(1001)`.