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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id C85C37FA5E for ; Sat, 13 May 2017 14:25:53 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=yminsky@janestreet.com; spf=Pass smtp.mailfrom=yminsky@janestreet.com; spf=None smtp.helo=postmaster@mxout3.mail.janestreet.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of yminsky@janestreet.com) identity=pra; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="yminsky@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of yminsky@janestreet.com designates 38.105.200.229 as permitted sender) identity=mailfrom; client-ip=38.105.200.229; receiver=mail2-smtp-roc.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 (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mxout3.mail.janestreet.com) identity=helo; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yminsky@janestreet.com"; x-sender="postmaster@mxout3.mail.janestreet.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AJkUwYxQo1BoFCEeVeOqirs8gENpsv+yvbD5Q0YIu?= =?us-ascii?q?jvd0So/mwa6zZxSN2/xhgRfzUJnB7Loc0qyN4vymATRIyK3CmUhKSIZLWR4BhJ?= =?us-ascii?q?detC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+?= =?us-ascii?q?KPjrFY7OlcS30P2594HObwlSijewZbx/IA+qoQn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?us-ascii?q?og6T4hDYKmCZ7PRoSsgLyawCe2BYZWZ2BDClCUC3jkbYSEW/EWaCKTOMBtiDIE?= =?us-ascii?q?VaLyA7MmgDOpskfZz7dmNefOsnkaspSl19x45vbejzk5+CZ5FIKb1DfeYXtzmz?= =?us-ascii?q?Y5TiUx2uhaoEpmyUbLhbl9gvpDFs175fpPXxwmL5PR06pxDNWkCVGJRcuAVFvz?= =?us-ascii?q?GobuOjo2VN9khoJXbg=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DPAQDR+hZZfeXIaSZdGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBFgEBAQMBAQEJAQEBhAyBDAeDZJt3gj+TNoIPLoV2AoUSB0AXAQEBAQE?= =?us-ascii?q?BAQEBAQESAQEJFghXgjMkgkIBAgMjHQEBLAsBDwsLDQICCR0CAiISAQUBChIGE?= =?us-ascii?q?xKJeQMVAwuhcz+LHWqCJoMJAQEFhBwDgxgBAQEBAQEBAwEBAQEBAQEBARcIEnm?= =?us-ascii?q?FVIR5gnyBZ4MSgmCHbAyWF4cci3+CBFWIKSOGRpJ7FB+BFSEBgT8vIAgZFUYZB?= =?us-ascii?q?oRJgipaiGwBAQE?= X-IPAS-Result: =?us-ascii?q?A0DPAQDR+hZZfeXIaSZdGgEBAQECAQEBAQgBAQEBFgEBAQM?= =?us-ascii?q?BAQEJAQEBhAyBDAeDZJt3gj+TNoIPLoV2AoUSB0AXAQEBAQEBAQEBAQESAQEJF?= =?us-ascii?q?ghXgjMkgkIBAgMjHQEBLAsBDwsLDQICCR0CAiISAQUBChIGExKJeQMVAwuhcz+?= =?us-ascii?q?LHWqCJoMJAQEFhBwDgxgBAQEBAQEBAwEBAQEBAQEBARcIEnmFVIR5gnyBZ4MSg?= =?us-ascii?q?mCHbAyWF4cci3+CBFWIKSOGRpJ7FB+BFSEBgT8vIAgZFUYZBoRJgipaiGwBAQE?= X-IronPort-AV: E=Sophos;i="5.38,335,1491256800"; d="scan'208";a="272955913" Received: from mxout3.mail.janestreet.com ([38.105.200.229]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 May 2017 14:25:52 +0200 Received: from [172.27.56.68] (helo=tot-qpr-mailcore1) by mxout3.mail.janestreet.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1d9W7L-0006Xn-G5 for caml-list@inria.fr; Sat, 13 May 2017 08:25:51 -0400 X-JS-Flow: external X-JS-Scanner-attachment: (ok) No attachments Received: by tot-qpr-mailcore1 with ocaml/mailcore/mailcore 1.0+90 (160ed8e8fef2) (envelope-from ) id BZFvtP-AatZF9-Op; 2017-05-13 08:25:51.470995-04:00 Received: from mail-vk0-f72.google.com ([209.85.213.72]) by mxgoog1.mail.janestreet.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from ) id 1d9W7L-00018x-Dz for caml-list@inria.fr; Sat, 13 May 2017 08:25:51 -0400 Received: by mail-vk0-f72.google.com with SMTP id u123so15508930vkb.14 for ; Sat, 13 May 2017 05:25:51 -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=g3KQ2jurl+ByeKPtRaIl7zu2W3JaOYUN1tNm/VBENww=; b=qXkpdeM0sOZ1RwYwYK1MRLWUmQTe6FTckpl/AWC54l+3Abfk6cbXv8KvKYb6YHk4nm LCDHR512rz5KW3JMMAoXt26a9DBdFwzoZetXcZbqDzt4wRL864Pd77kzDu25TsbXCuc8 EkZrO/p1LOmwmyOe/V0p2K46RppPzgP8mtcmw= 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=g3KQ2jurl+ByeKPtRaIl7zu2W3JaOYUN1tNm/VBENww=; b=k810qpE5+Fvm8pHNpPHo9rl/3FeudbC2dQmBEfZTOdA9nnJCl9J3xpPuj0xI0w9jrV Q6EgOhriL1vzjqW/CTvOgpfarD5XVeu+AS0CRcHEcisDGMUFjxnfdvS8p4xsSnbnLrOO 7cR4Ymu6jJ7l139lUr4rc5ej8bMVZXoepsJz54y+qekiCmT/v0E7L60Bh0/AkhYNkZeL huij4VjnVWF52qycsKJynKIqhHmpv4MUxidhLNqgI/RgHHV3GrV8VSKlwziyeorbw8lP 2lLCkIVzdvPUTCbbhE8OePqnpdiTz7T26zYvBFaBXwyA3tP6nMwp5B4HRqG+Z+BOmDbQ v1aQ== X-Gm-Message-State: AODbwcCa5xK+kHddajjnevjlBHpBjopLsChJUUQ+N/kmu6eDnPtu65jO bZ6y3HojpRA9nCL26THSsNd3ZXz43XBK1Cfe19KFv7Q9nOkKhYE/zudqu+Noe39GNdweS2PH9kw ULZf7HqIf6VwcNkIM X-Received: by 10.176.2.113 with SMTP id 104mr4537998uas.9.1494678350976; Sat, 13 May 2017 05:25:50 -0700 (PDT) X-Received: by 10.176.2.113 with SMTP id 104mr4537990uas.9.1494678350770; Sat, 13 May 2017 05:25:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.236.197 with HTTP; Sat, 13 May 2017 05:25:30 -0700 (PDT) In-Reply-To: References: <2490F692-502C-408E-9E60-30216557DF15@mail.uio.no> From:Yaron Minsky Date: Sat, 13 May 2017 08:25:30 -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:25:51-0400 X-JS-Processed-by: mailcore Subject: Re: [Caml-list] Is there a way to abort Stream.iter ? Also, as you can see here: https://github.com/janestreet/async_kernel/blob/master/src/pipe.mli#L525 Pipe.iter and Pipe.iter' will terminate if the callback throws. y On Sat, May 13, 2017 at 8:24 AM, Yaron Minsky wrot= e: > 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 wrot= e: >> 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(l= ine_stream_of_channel in_channel)=E2=80=99. >> >> Is there a way to abort the Stream.iter processing based on some conditi= on detected by the =E2=80=98process_line=E2=80=99 function? Could it be don= e by throwing an exception? Maybe I should use something else than Stream.i= ter ? >> >> /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