[Haskell-cafe] Faster timeout but is it correct?

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Mon Feb 21 10:27:45 CET 2011


Hi Bas,

> The solution is probably to reverse the order of: "unsafeUnmask $
> forkIO" to "forkIO $ unsafeUnmask". Or just use "forkIOUnmasked". The
> reason I didn't used that in the first place was that it was much
> slower for some reason.

The reason is probably that in order for the  forkIOUnmaske-d thread
to receive an exception (which it must, to be killed), it first has
to be activated at least once, to perform the unsafeUnmask. So the
worker thread's call to killThread will block. Now if there were a
way to specify the exception mask of the newly created thread directly,
it should be just as fast as the  unsafeUnmask . forkIO  version.

I have not checked the event manager based implementation in detail,
but from your numbers it looks like the best option at this time.

Best regards,

Bertram



More information about the Haskell-Cafe mailing list