summaryrefslogtreecommitdiff
path: root/src/Control
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-11-14 22:03:27 -0500
committerjoe <joe@jerkface.net>2017-11-14 22:03:27 -0500
commit69e0c86ff42f9f14c16791305828dcfdfd40baa8 (patch)
tree8c85edcdd4c6dfe56c9fe9badfeaa99084b1cc21 /src/Control
parent4df9b9c240219fc01bf9ee8f15a6a2ee80d2233b (diff)
More sensible DNSCache behavior for non-threaded runtime.
Diffstat (limited to 'src/Control')
-rw-r--r--src/Control/Concurrent/Lifted/Instrument.hs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Control/Concurrent/Lifted/Instrument.hs b/src/Control/Concurrent/Lifted/Instrument.hs
index 7e4a7356..41814d98 100644
--- a/src/Control/Concurrent/Lifted/Instrument.hs
+++ b/src/Control/Concurrent/Lifted/Instrument.hs
@@ -2,6 +2,7 @@
2module Control.Concurrent.Lifted.Instrument 2module Control.Concurrent.Lifted.Instrument
3 ( module Control.Concurrent.Lifted 3 ( module Control.Concurrent.Lifted
4 , forkIO 4 , forkIO
5 , forkOS
5 , fork 6 , fork
6 , labelThread 7 , labelThread
7 , threadsInformation 8 , threadsInformation
@@ -9,7 +10,7 @@ module Control.Concurrent.Lifted.Instrument
9 ) where 10 ) where
10 11
11import qualified Control.Concurrent.Lifted as Raw 12import qualified Control.Concurrent.Lifted as Raw
12import Control.Concurrent.Lifted hiding (fork) 13import Control.Concurrent.Lifted hiding (fork,forkOS)
13import Control.Exception (fromException) 14import Control.Exception (fromException)
14import Control.Monad.Trans.Control 15import Control.Monad.Trans.Control
15import System.IO.Unsafe 16import System.IO.Unsafe
@@ -46,9 +47,19 @@ forkIO :: IO () -> IO ThreadId
46forkIO = fork 47forkIO = fork
47{-# INLINE forkIO #-} 48{-# INLINE forkIO #-}
48 49
50forkOS :: (MonadBaseControl IO m, MonadIO m) => m () -> m ThreadId
51forkOS = instrumented Raw.forkOS
52{-# INLINE forkOS #-}
53
49fork :: (MonadBaseControl IO m, MonadIO m) => m () -> m ThreadId 54fork :: (MonadBaseControl IO m, MonadIO m) => m () -> m ThreadId
50fork action = do 55fork = instrumented Raw.fork
51 t <- Raw.fork $ do 56{-# INLINE fork #-}
57
58instrumented :: ( MonadBaseControl IO m
59 , MonadIO m) =>
60 (m () -> m ThreadId) -> m () -> m ThreadId
61instrumented rawFork action = do
62 t <- rawFork $ do
52 tid <- myThreadId 63 tid <- myThreadId
53 tm <- liftBase getCurrentTime 64 tm <- liftBase getCurrentTime
54 bracket_ (modifyThreads $! Map.insert tid (PerThread "" tm)) 65 bracket_ (modifyThreads $! Map.insert tid (PerThread "" tm))