What does interruptibility mean exactly?
Bas van Dijk
v.dijk.bas at gmail.com
Tue Jun 15 04:00:29 EDT 2010
On Mon, Jun 14, 2010 at 11:20 PM, Don Stewart <dons at galois.com> wrote:
>> I've a short question about interruptible operations. In the following
>> program is it possible for 'putMVar' to re-throw asynchronous
>> exceptions even when asynchronous exception are blocked/masked?
>> newEmptyMVar >>= \mv -> block $ putMVar mv x
>> The documentation in Control.Exception about interruptible
>> operations confused me:
>> "Some operations are interruptible, which means that they can receive
>> asynchronous exceptions even in the scope of a block. Any function
>> which may itself block is defined as interruptible..."
> I think the best definition of interruptible is in this paper:
> Section 5.3
Thanks for the link Don! Next time I will re-read the paper before asking ;-)
The definition makes it clear indeed:
"Any operation which may need to wait indefinitely for a resource
(e.g., takeMVar) may receive asynchronous exceptions even within an
enclosing block, BUT ONLY WHILE THE RESOURCE IS UNAVAILABLE"
So I guess I can update my threads package to use MVars again. Nice!
because they were a bit faster in an informal benchmark I performed
some time ago.
A later quote from 5.3 emphasizes the definition even more:
"...an interruptible operation cannot be interrupted if the resource
it is attempting to acquire is always available..."
The following darcs patch makes the definition of
interruptibility in the documentation in Control.Exception a bit
clearer in this regard:
More information about the Glasgow-haskell-users