[Haskell] What guarantees (if any) do interruptible operations have in presence of asynchronous exceptions?

Cat Dancer haskell at catdancer.ws
Tue Dec 5 08:50:36 EST 2006

>From the discussion of "Help needed interrupting accepting a network
connection", what we have so far is:

    * To break out of an "accept" call, an asynchronous exception is needed.

    * The presence of asynchronous exceptions complicates the other code
      used to report if "accept" completed or was interrupted, whether
      that code is written using MVar's or STM.

Thus the next question is what guarantees, if any, do interruptible
operations possess?

For example, suppose that inside of a "block", a putMVar operation was
guaranteed to either interrupt and allow an asynchronous exception to
be raised, or to complete the putMVar operation, but not both.

If this were true, then if you caught an asynchronous exception from
the putMVar operation, you'd know that a value was not put into the
MVar by the operation.

Then it would be easy to program with MVar's in the presence of
asynchronous exceptions.  When you caught an asynchronous exception,
you could set a flag, and then redo the putMVar.

The same question can be asked of other interruptible operations.

For the "accept" call itself, is it guaranteed (inside of a "block")
to either accept a connection, or be interrupted and allow an
asynchronous exception to be raised, but not both?

For STM, is "atomically" an interruptible operation?  If it is, what
guarantees does it offer in the presence of asynchronous exceptions?

More information about the Haskell mailing list