From: Jeremie Dimino <jdimino@janestreet.com>
To: Nicolas Ojeda Bar <N.Ojeda.Bar@dpmms.cam.ac.uk>
Cc: "caml-list@yquem.inria.fr" <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] async exceptions with lwt/async?
Date: Fri, 18 Oct 2013 10:02:33 +0100 [thread overview]
Message-ID: <CANhEzE5iVLtgyih1OBN+WogS9zmuQURu9HUeYCf2Jz9+mSCJFw@mail.gmail.com> (raw)
In-Reply-To: <A69C1CFF-ED2F-4F49-BAAE-EE5F5E13D605@dpmms.cam.ac.uk>
[-- Attachment #1: Type: text/plain, Size: 1129 bytes --]
Hi,
There is no real equivalent of Haskell's killthread in lwt or async. The
closest in lwt is Lwt.cancel: if a thread is blocked on a cancelable
operation, this one will fail with Lwt.Canceled. Cancelable operations
include: sockets and pipes IO, sleeping, waiting on an mvar, etc...
In async the way to do it is to pass an "interrupt" deferred (basically
just a [unit Deferred.t] value) down to low-level fd operations. When this
deferred becomes determined the operation in progress will be interrupted.
Hope that helps,
Jeremie
On Thu, Oct 17, 2013 at 7:34 PM, Nicolas Ojeda Bar <
N.Ojeda.Bar@dpmms.cam.ac.uk> wrote:
> Hi,
>
> Is there a way to raise an exception in a different thread than the
> currently executing one with lwt? What about J. Street's async?
>
> I am essentially looking for a replacement of Haskell's 'killthread'.
>
> Thank you very much,
> Nicolas
>
> --
> 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
>
--
Jeremie
[-- Attachment #2: Type: text/html, Size: 1941 bytes --]
prev parent reply other threads:[~2013-10-18 9:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-17 18:34 Nicolas Ojeda Bar
2013-10-18 9:02 ` Jeremie Dimino [this message]
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=CANhEzE5iVLtgyih1OBN+WogS9zmuQURu9HUeYCf2Jz9+mSCJFw@mail.gmail.com \
--to=jdimino@janestreet.com \
--cc=N.Ojeda.Bar@dpmms.cam.ac.uk \
--cc=caml-list@yquem.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