From: "Daniel Bünzli" <daniel.buenzli@epfl.ch>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Has the thread cancellation problem evolved ?
Date: Mon, 27 Aug 2007 14:24:34 +0200 [thread overview]
Message-ID: <07BE0325-B260-407C-A1BB-389D4C88311C@epfl.ch> (raw)
In-Reply-To: <1188214119.13927.16.camel@rosella.wigram>
Le 27 août 07 à 13:28, skaller a écrit :
> I agree with you rationale, but it isn't clear the conclusion follows
> that raise_in is acceptable.
>
> To give a simple pseudo code:
>
> begin
> let f = open_out filename in
> write f stuff;
> close f
> end
>
> which would work assuming write doesn't raise, will fail to
> work in the presence of async exceptions.
It won't fail to work, there is the possibility that f will never be
closed, that's it. The point is that the code written above should
not be written in a library (library IO routines should always take a
channel or a stream, not a filename, for other reasons aswell, e.g.
to IO on a socket). Such code should be written by the user of the
library, and if he knows he needs to handle cancellation he will act
accordingly. Note that you don't catch Sys_error here...
> This roughly means
> every resource acquisition MUST be guarded by a try/with
> which catches the async exception and releases the resource
> before re-raising it.
Yes but if you are not a sloppy programmer you already guard your
operations on channels to handle the various errors that can occur
and End_of_file. And if you are really not a sloppy programmer you
already have and use your own version of try/finally :
let apply f x ~finally y =
let res = try f x with exn -> finally y; raise exn in
finally y;
res
Anyway most of the things I would like to cancel are not functions
dealing with channels or locks but functions that do perform
intensive numerical computations. In the presence of a human user you
cannot let the ui hang for arbitrary long period of time, he should
be able to cancel if he gets bored.
Daniel
next prev parent reply other threads:[~2007-08-27 12:24 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-25 13:58 Daniel Bünzli
2007-08-25 15:29 ` [Caml-list] " skaller
2007-08-26 23:47 ` Daniel Bünzli
2007-08-27 0:18 ` Till Varoquaux
2007-08-27 4:38 ` skaller
2007-08-27 10:12 ` Daniel Bünzli
2007-08-27 11:28 ` skaller
2007-08-27 11:49 ` Jon Harrop
2007-08-27 12:24 ` Daniel Bünzli [this message]
2007-08-27 12:38 ` Jon Harrop
2007-08-27 13:09 ` Daniel Bünzli
2007-08-27 14:27 ` skaller
2007-08-27 7:55 ` Markus E L
2007-08-27 23:33 ` Gerd Stolpmann
2007-08-28 9:26 ` Daniel Bünzli
2007-08-28 11:42 ` Gerd Stolpmann
2007-08-28 14:46 ` Daniel Bünzli
2007-08-28 14:23 ` Gordon Henriksen
2007-08-28 14:35 ` Brian Hurt
2007-08-28 14:44 ` Daniel Bünzli
2007-08-28 14:54 ` Robert Fischer
2007-08-28 15:12 ` Brian Hurt
2007-08-28 15:32 ` Gordon Henriksen
2007-08-28 15:40 ` skaller
2007-08-29 8:12 ` Lionel Elie Mamane
2007-08-28 15:00 ` Gordon Henriksen
2007-08-25 15:44 ` skaller
2007-08-26 23:24 ` Alain Frisch
2007-08-25 15:57 ` Gordon Henriksen
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=07BE0325-B260-407C-A1BB-389D4C88311C@epfl.ch \
--to=daniel.buenzli@epfl.ch \
--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