From: Rodolphe Lepigre <rodolphe.lepigre@univ-savoie.fr>
To: caml-list@inria.fr
Subject: [Caml-list] Timeout
Date: Tue, 21 Apr 2015 02:18:34 +0200 [thread overview]
Message-ID: <20150421001834.GB23239@HPArchRod> (raw)
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/
next reply other threads:[~2015-04-21 0:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-21 0:18 Rodolphe Lepigre [this message]
2015-04-21 0:54 ` Benjamin Greenman
2015-04-21 8:25 ` Rodolphe Lepigre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150421001834.GB23239@HPArchRod \
--to=rodolphe.lepigre@univ-savoie.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox