OMNI_SLEEP
MACRO

OMNI_SLEEP - A helper macro for millisecond sleeps

SYNOPSIS top

Helper macro to sleep for a specified number of milliseconds. If 1 ms is needed (which won't realistically happen unless on a RTOS), call OMNI_SLEEP1 which is optimized for 1 ms sleeps.

DESCRIPTION top

To enable millisecond sleep capabilities cross-platform, temporaries are needed on non-Windows platforms; to this, when omni::sync::sleep is called, this macro is utilized. As well, in other areas of the framework where a sleep is called in a tight loop, this macro is utilized.

Example:
OMNI_SLEEP_INIT();
while (dorun) {
    OMNI_SLEEP(1000); // 1s sleep
}
In this example, OMNI_SLEEP_INIT is an empty macro on Windows platforms and the sleep variables needed on others and OMNI_SLEEP expands to the Windows Sleep function and the nanosleep function on others to achieve millisecond sleep resolution.

CONSIDERATIONS top

While you might specify a value less than 10ms, it can be typical for a sleep to take approximately 10-15ms due to time slicing and kernel timing.

PLATFORM SPECIFIC top

OMNI_SLEEP expands to the Windows Sleep API and the nanosleep function on others to achieve millisecond sleep resolution.

NOTES top

None.