
On 18/11/2010 11:31, Mitar wrote:
Hi!
On Wed, Nov 17, 2010 at 12:00 PM, Simon Marlow
wrote: That's hard to do, because the runtime system has no knowledge of exception types, and I'm not sure I like the idea of baking that knowledge into the RTS.
But currently it does have a knowledge of interruptible and uninterruptible exceptions? So adding another which would ctrl-c interrupt?
The RTS knows when a thread is blocked, which is when it becomes interruptible. It doesn't need to know about different kinds of exeptions. In fact, when an exception is thrown it might well be unevaluated.
The point of maskUninterruptible is for those hoefully rare rare cases where (a) it's really inconvenient to deal with async exceptions and (b) you have some external guarantee that the critical section won't block.
But is it possible to make an uninterruptible code section which can timeout?
then it isn't uninterruptible, because the timeout can interrupt it. If you can tolerate a timeout exception, then you can tolerate other kinds of async exception too.
Because once you enter maskUninterruptible probably System.Timeout does not work anymore? I see uses of maskUninterruptible (or some derivation of it, preferably) if:
- user would still be able to interrupt it - you could specify some timeout or some other condition after which the code section would be interrupted, so you could try for example to deal with some cleanup code (and you do not want interrupts there) but if this cleanup code hangs you still want some way to kill it then
Currently, with this absolute/all approach maskUninterruptible is really not useful much because it masks too much. But I would see a lot more useful something which would still allow me (and only me, as a programmer) to interrupt it or user (because user should know what he/she does). And this is why I argue for some way of being able to specify which interrupts you still allow: like mask everything except... (user interrupts, my special exception meant for cleanup code hanging conditions...).
My main question is then, why do you want to use maskUninterruptible rather than just mask? Can you give a concrete example? Cheers, Simon