proper cleanup;
authorwenzelm
Fri, 21 Dec 2018 16:08:39 +0100
changeset 69495 c34dfa431b89
parent 69494 7e44f8e2cc49
child 69496 5256e7f26640
proper cleanup;
src/Tools/Haskell/Haskell.thy
--- a/src/Tools/Haskell/Haskell.thy	Fri Dec 21 16:02:00 2018 +0100
+++ b/src/Tools/Haskell/Haskell.thy	Fri Dec 21 16:08:39 2018 +0100
@@ -1748,6 +1748,10 @@
         Nothing -> (infos, ())
         Just info -> (Map.insert id (f info) infos, ()))
 
+delete_info :: ThreadId -> IO ()
+delete_info id =
+  atomicModifyIORef' global_state (\infos -> (Map.delete id infos, ()))
+
 
 {- thread properties -}
 
@@ -1789,7 +1793,8 @@
           (do
             id <- Concurrent.myThreadId
             atomicModifyIORef' global_state (init_info id uuid)
-            restore body) >>= finally))
+            restore body)
+         >>= (\res -> do id <- Concurrent.myThreadId; delete_info id; finally res)))
   return (id, uuid, result)
 
 fork :: IO a -> IO (Fork a)