Sleeping less than a second in OCaml

The Unix.sleep function can suspend the program for whole seconds, but how can you suspend it for less than a second?

Answers


The classical Unix solution for this is to use select() with no file descriptors:

let minisleep (sec: float) =
    ignore (Unix.select [] [] [] sec)

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.


from Unix module

val sleepf : float -> unit

Stop execution for the given number of seconds. Like sleep, but fractions of seconds are supported.


Need Your Help

What is the suggested way to handle exceptions during in a MVVMCross application?

windows-phone-7 xamarin.ios xamarin.android mvvmcross

We're developing a cross platform application for iOS, Android and WP7 by using MVVMCross framework and I'm missing a method in MvxApplication that I can override which can serves as the platform n...

Get JSON key name using GSON

java json gson json-deserialization

I have a JSON array which contains objects such as this: