English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Has the thread cancellation problem evolved ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-08-27 (12:49)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Has the thread cancellation problem evolved ?
On Monday 27 August 2007 13:24:34 Daniel Bünzli wrote:
> 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

Ironically, that's broken. :-)

If your handler "finally" raises an exception then it would replace the Abort 
exception. You should ignore any exception raised by "finally" if "f" raises 
an exception.

> 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.

Then write in CPS and weave an abortable continuation between each step.

Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists