RE: Asynchronous exceptions and "resume"

Hi all, is there a way, or is it planned to, or has anyone published articles on... resuming from asynchronous exceptions?
I mean: it would be useful there was a
suspend :: ThreadID -> IO ()
where the result is the remaining computation of the other thread, wich one could forkIO again, or simply run in the current thread.
This is fairly easy to implement in GHC. Simple call Schedule.c:raiseAsync() with NULL for the exception, and make it return the final closure after it has stripped the thread's stack. Entering that closure should restart the thread's computation exactly where it left off. If the thread was blocked on something (eg. takeMVar), then it should restart the blocking operation. The types aren't quite right: the closure you get back will behave like an application of unsafePerformIO, so you will need to wrap it using eg. Control.Exception.evaluate to get an IO action. I'm sure there are plenty of cool uses for this... Cheers, Simon
participants (1)
-
Simon Marlow