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 7F69F7FA5E for ; Sat, 13 May 2017 14:24:41 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=yminsky@janestreet.com; spf=Pass smtp.mailfrom=yminsky@janestreet.com; spf=None smtp.helo=postmaster@mxout1.mail.janestreet.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of yminsky@janestreet.com) identity=pra; client-ip=38.105.200.78; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of yminsky@janestreet.com designates 38.105.200.78 as permitted sender) identity=mailfrom; client-ip=38.105.200.78; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.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@mxout1.mail.janestreet.com) identity=helo; client-ip=38.105.200.78; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="postmaster@mxout1.mail.janestreet.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3ACf5RdRFGLDd4IxzrdIXoNZ1GYnF86YWxBRYc798d?= =?us-ascii?q?s5kLTJ7yp8iwAkXT6L1XgUPTWs2DsrQf2raQ6/iocFdDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZr?= =?us-ascii?q?KeTpAI7SiNm82/yv95HJbQhFgDWwbaluIBmq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Sj5SZ3OqX6?= =?us-ascii?q?0m/D07CYSmDZ3CRo+3mrCB0j27TdVqYTVkDVbEMnPldp6JQb9YaiWUZMxlnz0f?= =?us-ascii?q?WKKJQII72ArosgismJR9Ke+ByyQCspSr8dlz/O7C3UUj8D1yFMeM+2OESWxvgn?= =?us-ascii?q?kFSiNw16d69x8ugmyf2LR11qQLXedY4OlEB0JnbJM=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DPAQDU+RZZfU7IaSZdGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBFQEBAQECAQEBAQgBAQEBhAyBDAeDZJt3gj+VRSyFeAKFEgdCFQEBAQE?= =?us-ascii?q?BAQEBAQEBEgEBCxQIV4IzJIJCAQIDIx0BASwLAQ8LCw0CAgkdAgIiEgEFAQoSB?= =?us-ascii?q?hMICol5AxUDC6F4P4sdaoImgwkBAQWEHAODGAEBAQEBAQEDAQEBAQEBAQEBFwg?= =?us-ascii?q?SeYVUhHmEY4MSgmABh2sMlheHHIt/ggRViCkjhkaSexQfgRU1gSwvIAgZFUYZB?= =?us-ascii?q?oRJgipaiGwBAQE?= X-IPAS-Result: =?us-ascii?q?A0DPAQDU+RZZfU7IaSZdGgEBAQECAQEBAQgBAQEBFQEBAQE?= =?us-ascii?q?CAQEBAQgBAQEBhAyBDAeDZJt3gj+VRSyFeAKFEgdCFQEBAQEBAQEBAQEBEgEBC?= =?us-ascii?q?xQIV4IzJIJCAQIDIx0BASwLAQ8LCw0CAgkdAgIiEgEFAQoSBhMICol5AxUDC6F?= =?us-ascii?q?4P4sdaoImgwkBAQWEHAODGAEBAQEBAQEDAQEBAQEBAQEBFwgSeYVUhHmEY4MSg?= =?us-ascii?q?mABh2sMlheHHIt/ggRViCkjhkaSexQfgRU1gSwvIAgZFUYZBoRJgipaiGwBAQE?= X-IronPort-AV: E=Sophos;i="5.38,335,1491256800"; d="scan'208";a="223505651" Received: from mxout1.mail.janestreet.com ([38.105.200.78]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 May 2017 14:24:40 +0200 Received: from [172.27.56.106] (helo=tot-qpr-mailcore2) by mxout1.mail.janestreet.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1d9W6A-00047c-K6 for caml-list@inria.fr; Sat, 13 May 2017 08:24:38 -0400 X-JS-Flow: external X-JS-Scanner-attachment: (ok) No attachments Received: by tot-qpr-mailcore2 with ocaml/mailcore/mailcore 1.0+90 (160ed8e8fef2) (envelope-from ) id BZFvsG-A35k8r-SO; 2017-05-13 08:24:38.586029-04:00 Received: from mail-vk0-f71.google.com ([209.85.213.71]) by mxgoog1.mail.janestreet.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from ) id 1d9W6A-0000md-Hq for caml-list@inria.fr; Sat, 13 May 2017 08:24:38 -0400 Received: by mail-vk0-f71.google.com with SMTP id p85so5550783vkd.10 for ; Sat, 13 May 2017 05:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=vtIM6ubQ3+4vaBgl3OQYRmOQbLPAEUNe5n27TGNAs8g=; b=WK6eoQ/jo8LPLB1CTSmLaf1qpumqv8R9JotQ0R26K0+N3D5rEWcps9tIuqsE0bCnj5 L/CiOu1jLS6IykjYYxnCt42fa7a42EPpIZyHyVVgU5cPOJT+csU87zD6wk1yCdkGUJgc 6Ax9qg5c0puw0MalVMH4s8qgDyphbGiZhnbPQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=vtIM6ubQ3+4vaBgl3OQYRmOQbLPAEUNe5n27TGNAs8g=; b=hZR4jdNijx0Ezi0H2+IX9odcxM977eyfMnWS2tl9aeGbRe0bYdG4io8n0TVQuEWckv bfeW0pHuZuHb9L4sF9cwalo8iT4CbiM7msZuu0UL8NxYVxZyqFsvalAynRWFuXvtt025 aL+sSUkm8Ja2O1LIUP0Vqmog60PZnlOcBzFP078I/YdUh32gCnotZIfC7aNgSJkHLe0O yoEnz05n1iA98O2udcN+93jKT3ISDkgbvTRf7klQ41ODRxOeHg//ZGsAia8jIQuduatN 5QQwvzGmUBt/WKj8viqC498h+pUz1rjWkL61UzEXDeGoj9UB1buK861oQUoerQRR3G7K 08LQ== X-Gm-Message-State: AODbwcC/bWot18qltu9BOlwhde71yUSTlgdVi+7cxBUPXufgnNNhMT+d 38ZDDO3CRgR6nmJJdQX1SVvK5AYDp7ZLKrkTnJR/BsKf4jZui7DViRZjoNd/c1Y7OMf5IbzXzmK OjmN0WUM9csuBpPlo X-Received: by 10.176.90.140 with SMTP id w12mr4829012uae.53.1494678278092; Sat, 13 May 2017 05:24:38 -0700 (PDT) X-Received: by 10.176.90.140 with SMTP id w12mr4829005uae.53.1494678277884; Sat, 13 May 2017 05:24:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.236.197 with HTTP; Sat, 13 May 2017 05:24:17 -0700 (PDT) In-Reply-To: <2490F692-502C-408E-9E60-30216557DF15@mail.uio.no> References: <2490F692-502C-408E-9E60-30216557DF15@mail.uio.no> From:Yaron Minsky Date: Sat, 13 May 2017 08:24:17 -0400 Message-ID: To:Jon Kleiser Cc:"caml-list@inria.fr" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-JS-Exim-Data-Received: 2017-05-13 08:24:38-0400 X-JS-Processed-by: mailcore Subject: Re: [Caml-list] Is there a way to abort Stream.iter ? First of all, you should probably use a Pipe.t rather than a Stream.t. Streams don't provide you with a way of pushing back, meaning the process that's filling data into the Stream won't slow down if you're slow in draining data from it. Pipes give you a mechanism for doing this, in that a Pipe has a bounded amount of slack. For pipes, when I want to control the exit time, I'll typically do a recursive loop using Pipe.read or Pipe.read'. You can do something similar with streams. y On Fri, May 12, 2017 at 10:34 AM, Jon Kleiser wrote: > In my little program here = I=E2=80=99m reading and processing a text file by doing this: > > let process_lines lines =3D > let start_time =3D Sys.time () in > Stream.iter process_line lines; > let finish_time =3D Sys.time () in > Printf.printf "\nTime used: %f secs\n" (finish_time -. start_time) > > . . . where the =E2=80=98lines=E2=80=99 input is coming from =E2=80=98(li= ne_stream_of_channel in_channel)=E2=80=99. > > Is there a way to abort the Stream.iter processing based on some conditio= n detected by the =E2=80=98process_line=E2=80=99 function? Could it be done= by throwing an exception? Maybe I should use something else than Stream.it= er ? > > /Jon > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs