caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Teller <David.Teller@ens-lyon.org>
To: OCaml <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] The best way to circumvent the lack of Thread.kill ?
Date: Wed, 02 Nov 2005 17:00:08 +0000	[thread overview]
Message-ID: <1130950809.4565.42.camel@calaf.rn.informatics.scitech.susx.ac.uk> (raw)
In-Reply-To: <4368E835.7090501@barettadeit.com>

Thanks for the answer.

 A (unit Event.channel) or a (exn Event.channel), combined with 
(Event.poll), or perhaps a simple (bool Event.channel), would indeed
permit soft-killing a thread during a synchronization phase meant
explicitly for that purpose. A thunk computation could even generalize
this to actual communications, at the price of a somewhat strange type.

 However, in my mind, all these solutions are the channel equivalent of
manual error-handling -- something akin to a function returning an ('a
option) instead of an 'a because the result None is reserved for errors.
I'm still slightly puzzled as to why this distant killing/raising is not
a core feature of channels. After all, unless I'm mistaken, channels are
a manner of implementing continuations. I tend to believe I should be
able to raise an error (a hypothetical Event.raise/Event.kill) instead
of returning/passing a value (as in Event.send).

 Or did I miss something ?

Cheers,
 David



On Wed, 2005-11-02 at 17:24 +0100, Alessandro Baretta wrote:
> David Teller wrote:
> >  I would have figured that the best way to properly kill a thread would
> > be to have some form of channel (i.e. Events.t)-based communication
> > between threads -- and then killing the channel.
> > 
> >  Trouble is that, as I've just realized, there is no such facility as
> > killing/sending an exception through a channel. Does anyone know why ?
> 
> Event.channel is a type constructor which takes an argument identifying 
> the type of objects that are sent over the channel. You can send thunk 
> computations ((unit -> 'a) Event.channel), which may very well raise an 
> exception. Or you can simply send an exception (exn Event.channel). 
> Finally, you can send "()" on a channel (unit Event.channel), whose sole 
>   purpose is to communicate soft-kill requests.
> 
> Alex
-- 
Read, write and publish e-books,
 Free software, Open standards, Open source,
  The OpenBerg project -- http://www.openberg.org


  reply	other threads:[~2005-11-02 17:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-02  9:52 Julien Narboux
2005-11-02 10:54 ` [Caml-list] " Richard Jones
2005-11-02 11:22   ` Julien Narboux
2005-11-02 13:00     ` Jacques Garrigue
2005-11-02 12:57       ` Julien Narboux
2005-11-02 13:23 ` Gerd Stolpmann
2005-11-02 14:00   ` Gerd Stolpmann
2005-11-02 14:32   ` Julien Narboux
2005-11-02 15:07     ` Gerd Stolpmann
2005-11-02 14:53 ` David Teller
2005-11-02 16:24   ` Alessandro Baretta
2005-11-02 17:00     ` David Teller [this message]
2005-11-02 18:43       ` Alessandro Baretta
2005-11-02 18:29         ` David Teller
2005-11-08 20:36           ` Jonathan Bryant
2005-11-09  1:18             ` Grégory Guyomarc'h
2005-11-09 12:37             ` Richard Jones
     [not found]             ` <4371A0A6.4010306@laposte.net>
2005-11-09 13:32               ` Jonathan Bryant
2005-11-02 11:33 EL CHAAR Rabih   SGAM/AI/SAM
2005-11-08  3:23 ` Igor Pechtchanski

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=1130950809.4565.42.camel@calaf.rn.informatics.scitech.susx.ac.uk \
    --to=david.teller@ens-lyon.org \
    --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;
as well as URLs for NNTP newsgroup(s).