git.iko.soy/distributed-process
on master help sign in
Workaround for throwTo problem that can potentially block.
commit8055a5ffe110efb86fe0bcd3e2d3f5300cfcb820 authorAlexander Vershilov <alexander.vershilov@gmail.com> dateMon 2 Mar 2015, 20:16 (12 years ago) parent4d3472a
1 file changed+3−1
src/Control/Distributed/Process/Node.hs+3−1
src/Control/Distributed/Process/Node.hs+3−1
@@ -1127,7 +1127,9 @@ postMessage pid msg = do
11271127throwException :: Exception e => ProcessId -> e -> NC ()
11281128throwException pid e = do
11291129 node <- ask
1130− liftIO $ withLocalProc node pid $ \p -> throwTo (processThread p) e
1130+ -- throwTo blocks until the exception is received by the target thread.
1131+ -- We fork a helper thread to avoid blocking the node controller.
1132+ liftIO $ withLocalProc node pid $ \p -> void $ forkIO $ throwTo (processThread p) e
11311133
11321134withLocalProc :: LocalNode -> ProcessId -> (LocalProcess -> IO ()) -> IO ()
11331135withLocalProc node pid p =