Reputation: 3520
The Unix.sleep
function can suspend the program for whole seconds, but how can you suspend it for less than a second?
Upvotes: 15
Views: 7906
Reputation: 3088
from Unix module
val sleepf : float -> unit
Stop execution for the given number of seconds. Like sleep, but fractions of seconds are supported.
Upvotes: 16
Reputation: 66823
The classical Unix solution for this is to use select() with no file descriptors:
let minisleep (sec: float) =
ignore (Unix.select [] [] [] sec)
Upvotes: 14
Reputation: 3520
The Thread.delay
function pauses the thread for the given number of seconds, but it takes a float, allowing you to pause the thread for less than a second.
Upvotes: 15