From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 0D0CD7FCEF for ; Tue, 21 Apr 2015 02:18:37 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of rlepigre@gmail.com) identity=pra; client-ip=74.125.82.53; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="rlepigre@gmail.com"; x-sender="rlepigre@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of rlepigre@gmail.com designates 74.125.82.53 as permitted sender) identity=mailfrom; client-ip=74.125.82.53; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="rlepigre@gmail.com"; x-sender="rlepigre@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wg0-f53.google.com) identity=helo; client-ip=74.125.82.53; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="rlepigre@gmail.com"; x-sender="postmaster@mail-wg0-f53.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DNAQDalTVVmzVSfUpbFoJQeFyDF4lvt2ZlCYFLhX6BSTgUAQEBAQEBAREBAQEBAQYLCwkULoQ5EQQLAQ0BOQMNBR8CBSECEQUgAQUBUAeHdQMRAQQIpg2DLj4xiziEYYoVJw2FSAEFDoETihaFIYJSL4EWBY8NhhqGJIFakX81gRVbgQwBAQEBBgEBAQERIR2BU22CRAEBAQ X-IPAS-Result: A0DNAQDalTVVmzVSfUpbFoJQeFyDF4lvt2ZlCYFLhX6BSTgUAQEBAQEBAREBAQEBAQYLCwkULoQ5EQQLAQ0BOQMNBR8CBSECEQUgAQUBUAeHdQMRAQQIpg2DLj4xiziEYYoVJw2FSAEFDoETihaFIYJSL4EWBY8NhhqGJIFakX81gRVbgQwBAQEBBgEBAQERIR2BU22CRAEBAQ X-IronPort-AV: E=Sophos;i="5.11,612,1422918000"; d="scan'208";a="112197466" Received: from mail-wg0-f53.google.com ([74.125.82.53]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 21 Apr 2015 02:18:36 +0200 Received: by wgsk9 with SMTP id k9so196008278wgs.3 for ; Mon, 20 Apr 2015 17:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:mime-version:content-type :content-disposition:content-transfer-encoding:user-agent; bh=Zt1fggXgDGRwqbOpVBPDG48VH2KRJCKQbOhU7kbuKbE=; b=OKJXe6t52zApku4p/PryRAW6Yl2UyqY57Rrp0tOns+GPQtKSooHeYhSR+7a6bQ3weQ I9dT05NHelW+RvqvSNYY6N8IaBy1oQvRNCRc+uHmfWUDidP39Se88PNK0Ht6Fk7h7taQ HBRP0/zzLARu2TDkEkcH0gPkbXKIaByTKG0sgIPUcQtb5oZIDZt6GRde6tm9nxQY54bl XR8nchBT6M5V3e6TKGTduGFsADf1ixb2t2e3xk0hdCV3LKilGIwEBjw+6KHBOGnxiQl/ UcazSbnZdp4EM09k3WvC3ShCYSYxU4b1gBrJQemo9q6Bz2xBntR7H3al80cqLxMgh9sV QloQ== X-Received: by 10.194.104.201 with SMTP id gg9mr34774586wjb.113.1429575516026; Mon, 20 Apr 2015 17:18:36 -0700 (PDT) Received: from localhost ([2a01:e35:399a:59e0:ae7b:a1ff:feb1:4789]) by mx.google.com with ESMTPSA id ha4sm17328938wib.0.2015.04.20.17.18.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2015 17:18:35 -0700 (PDT) Sender: Rodolphe Lepigre Date: Tue, 21 Apr 2015 02:18:34 +0200 From: Rodolphe Lepigre To: caml-list@inria.fr Message-ID: <20150421001834.GB23239@HPArchRod> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.23 (2014-03-12) Subject: [Caml-list] Timeout 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/