From d8c8a1a857709334949d680d6afa274b7c6c7809 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Tue, 24 May 2011 11:02:52 +0100 Subject: [PATCH] document the behaviour of throwTo to the current thread (#4888) --- GHC/Conc/Sync.lhs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/GHC/Conc/Sync.lhs b/GHC/Conc/Sync.lhs index 0214a56..f16ee3f 100644 --- a/GHC/Conc/Sync.lhs +++ b/GHC/Conc/Sync.lhs @@ -373,9 +373,17 @@ thread reaches a /safe point/, where a safe point is where memory allocation occurs. Some loops do not perform any memory allocation inside the loop and therefore cannot be interrupted by a 'throwTo'. -Blocked 'throwTo' is fair: if multiple threads are trying to throw an -exception to the same target thread, they will succeed in FIFO order. - +If the target of 'throwTo' is the calling thread, then the behaviour +is the same as 'Control.Exception.throwIO', except that the exception +is thrown as an asynchronous exception. This means that if there is +an enclosing pure computation, which would be the case if the current +IO operation is inside 'unsafePerformIO' or 'unsafeInterleaveIO', that +computation is not permanently replaced by the exception, but is +suspended as if it had received an asynchronous exception. + +Note that if 'throwTo' is called with the current thread as the +target, the exception will be thrown even if the thread is currently +inside 'mask' or 'uninterruptibleMask'. -} throwTo :: Exception e => ThreadId -> e -> IO () throwTo (ThreadId tid) ex = IO $ \ s -> -- 1.7.10.4