Commit 8e66365b authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺

Unlit overlooked GHC/Conc/Sync.lhs

This is a follow-up commit to df3b1d43
parent 65dc594b
\begin{code}
{-# LANGUAGE Unsafe #-} {-# LANGUAGE Unsafe #-}
{-# LANGUAGE CPP {-# LANGUAGE CPP
, NoImplicitPrelude , NoImplicitPrelude
...@@ -118,15 +117,11 @@ import GHC.Show ( Show(..), showString ) ...@@ -118,15 +117,11 @@ import GHC.Show ( Show(..), showString )
import GHC.Weak import GHC.Weak
infixr 0 `par`, `pseq` infixr 0 `par`, `pseq`
\end{code}
%************************************************************************ -----------------------------------------------------------------------------
%* * -- 'ThreadId', 'par', and 'fork'
\subsection{@ThreadId@, @par@, and @fork@} -----------------------------------------------------------------------------
%* *
%************************************************************************
\begin{code}
data ThreadId = ThreadId ThreadId# deriving( Typeable ) data ThreadId = ThreadId ThreadId# deriving( Typeable )
-- ToDo: data ThreadId = ThreadId (Weak ThreadId#) -- ToDo: data ThreadId = ThreadId (Weak ThreadId#)
-- But since ThreadId# is unlifted, the Weak type must use open -- But since ThreadId# is unlifted, the Weak type must use open
...@@ -528,19 +523,15 @@ mkWeakThreadId :: ThreadId -> IO (Weak ThreadId) ...@@ -528,19 +523,15 @@ mkWeakThreadId :: ThreadId -> IO (Weak ThreadId)
mkWeakThreadId t@(ThreadId t#) = IO $ \s -> mkWeakThreadId t@(ThreadId t#) = IO $ \s ->
case mkWeakNoFinalizer# t# t s of case mkWeakNoFinalizer# t# t s of
(# s1, w #) -> (# s1, Weak w #) (# s1, w #) -> (# s1, Weak w #)
\end{code}
%************************************************************************ -----------------------------------------------------------------------------
%* * -- Transactional heap operations
\subsection[stm]{Transactional heap operations} -----------------------------------------------------------------------------
%* *
%************************************************************************
TVars are shared memory locations which support atomic memory -- TVars are shared memory locations which support atomic memory
transactions. -- transactions.
\begin{code}
-- |A monad supporting atomic memory transactions. -- |A monad supporting atomic memory transactions.
newtype STM a = STM (State# RealWorld -> (# State# RealWorld, a #)) newtype STM a = STM (State# RealWorld -> (# State# RealWorld, a #))
deriving Typeable deriving Typeable
...@@ -733,11 +724,10 @@ writeTVar (TVar tvar#) val = STM $ \s1# -> ...@@ -733,11 +724,10 @@ writeTVar (TVar tvar#) val = STM $ \s1# ->
case writeTVar# tvar# val s1# of case writeTVar# tvar# val s1# of
s2# -> (# s2#, () #) s2# -> (# s2#, () #)
\end{code} -----------------------------------------------------------------------------
-- MVar utilities
MVar utilities -----------------------------------------------------------------------------
\begin{code}
withMVar :: MVar a -> (a -> IO b) -> IO b withMVar :: MVar a -> (a -> IO b) -> IO b
withMVar m io = withMVar m io =
mask $ \restore -> do mask $ \restore -> do
...@@ -755,15 +745,10 @@ modifyMVar_ m io = ...@@ -755,15 +745,10 @@ modifyMVar_ m io =
(\e -> do putMVar m a; throw e) (\e -> do putMVar m a; throw e)
putMVar m a' putMVar m a'
return () return ()
\end{code}
%************************************************************************
%* *
\subsection{Thread waiting}
%* *
%************************************************************************
\begin{code} -----------------------------------------------------------------------------
-- Thread waiting
-----------------------------------------------------------------------------
-- Machinery needed to ensureb that we only have one copy of certain -- Machinery needed to ensureb that we only have one copy of certain
-- CAFs in this module even when the base package is present twice, as -- CAFs in this module even when the base package is present twice, as
...@@ -824,5 +809,3 @@ setUncaughtExceptionHandler = writeIORef uncaughtExceptionHandler ...@@ -824,5 +809,3 @@ setUncaughtExceptionHandler = writeIORef uncaughtExceptionHandler
getUncaughtExceptionHandler :: IO (SomeException -> IO ()) getUncaughtExceptionHandler :: IO (SomeException -> IO ())
getUncaughtExceptionHandler = readIORef uncaughtExceptionHandler getUncaughtExceptionHandler = readIORef uncaughtExceptionHandler
\end{code}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment