caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Timeout
@ 2015-04-21  0:18 Rodolphe Lepigre
  2015-04-21  0:54 ` Benjamin Greenman
  0 siblings, 1 reply; 3+ messages in thread
From: Rodolphe Lepigre @ 2015-04-21  0:18 UTC (permalink / raw)
  To: caml-list

I was wondering: is there a standard way to stop a computation after, say,
a given number of milliseconds (or seconds) in OCaml?

For instance I would like to have a function

  exception Timeout
  val exec : int -> ('a -> 'b) -> 'a -> 'b

such that [exec t f x] computes [f x] but raises [Timeout] in case the
computation did not end before [t] milliseconds (or seconds).

My guess would be that I need to use some Unix signals magic. Has anyone
come up with a clean solution to this problem?

Thanks!

Rodolphe
-- 
Rodolphe Lepigre
LAMA, Université de Savoie, FRANCE
http://lama.univ-savoie.fr/~lepigre/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-21  8:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-21  0:18 [Caml-list] Timeout Rodolphe Lepigre
2015-04-21  0:54 ` Benjamin Greenman
2015-04-21  8:25   ` Rodolphe Lepigre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).