[project @ 2005-10-25 11:13:53 by simonmar]
[ghc-base.git] / GHC / Conc.lhs
index f56cf61..f1b4d61 100644 (file)
@@ -146,7 +146,13 @@ target thread.  The calling thread can thus be certain that the target
 thread has received the exception.  This is a useful property to know
 when dealing with race conditions: eg. if there are two threads that
 can kill each other, it is guaranteed that only one of the threads
-will get to kill the other. -}
+will get to kill the other.
+
+If the target thread is currently making a foreign call, then the
+exception will not be raised (and hence 'throwTo' will not return)
+until the call has completed.  This is the case regardless of whether
+the call is inside a 'block' or not.
+ -}
 throwTo :: ThreadId -> Exception -> IO ()
 throwTo (ThreadId id) ex = IO $ \ s ->
    case (killThread# id ex s) of s1 -> (# s1, () #)
@@ -476,7 +482,7 @@ threadDelay time
 
 -- On Windows, we just make a safe call to 'Sleep' to implement threadDelay.
 #ifdef mingw32_HOST_OS
-foreign import ccall safe "Sleep" c_Sleep :: CInt -> IO ()
+foreign import stdcall safe "Sleep" c_Sleep :: CInt -> IO ()
 #endif
 
 foreign import ccall unsafe "rtsSupportsBoundThreads" threaded :: Bool
@@ -613,7 +619,9 @@ service_loop wakeup readfds writefds ptimeval old_reqs old_delays = do
            s <- peek p         
            if (s == 0xff) 
              then return ()
-             else c_startSignalHandler (fromIntegral s)
+             else do sp <- peekElemOff handlers (fromIntegral s)
+                     quickForkIO (deRefStablePtr sp)
+                     return ()
 
   takeMVar prodding
   putMVar prodding False
@@ -638,8 +646,7 @@ prodServiceThread = do
     else return ()
   putMVar prodding True
 
-foreign import ccall unsafe "startSignalHandler"
-  c_startSignalHandler :: CInt -> IO ()
+foreign import ccall "&signal_handlers" handlers :: Ptr (StablePtr (IO ()))
 
 foreign import ccall "setIOManagerPipe"
   c_setIOManagerPipe :: CInt -> IO ()