I am in need of a timeout function, that will interrupt the current computation after an
x amount of time. This needs to have a sub-second resolution, so I cannot use
Unix.alarm. I will also use this frequently, so forking the process all the time is also not an option. Ocaml multicore is also not an option for now. The best I came up with is to have two long-running processes communicate with each other over a socket to repeatedly set timeouts and send interrupts. lwt-parallel looks like a good library to implement this, but unfortunately it is only available for OCaml < 4.08.0 and I am using the new monad notations in 4.08.0
But I cannot be the first person to run into this issue. Does anyone have any experience with this problem? Is there a good implementation laying around somewhere?