Added a function to sleep a guaranteed duration.