diff options
Diffstat (limited to 'src/Control')
-rw-r--r-- | src/Control/Concurrent/Lifted/Instrument.hs | 17 |
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 @@ | |||
2 | module Control.Concurrent.Lifted.Instrument | 2 | module 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 | ||
11 | import qualified Control.Concurrent.Lifted as Raw | 12 | import qualified Control.Concurrent.Lifted as Raw |
12 | import Control.Concurrent.Lifted hiding (fork) | 13 | import Control.Concurrent.Lifted hiding (fork,forkOS) |
13 | import Control.Exception (fromException) | 14 | import Control.Exception (fromException) |
14 | import Control.Monad.Trans.Control | 15 | import Control.Monad.Trans.Control |
15 | import System.IO.Unsafe | 16 | import System.IO.Unsafe |
@@ -46,9 +47,19 @@ forkIO :: IO () -> IO ThreadId | |||
46 | forkIO = fork | 47 | forkIO = fork |
47 | {-# INLINE forkIO #-} | 48 | {-# INLINE forkIO #-} |
48 | 49 | ||
50 | forkOS :: (MonadBaseControl IO m, MonadIO m) => m () -> m ThreadId | ||
51 | forkOS = instrumented Raw.forkOS | ||
52 | {-# INLINE forkOS #-} | ||
53 | |||
49 | fork :: (MonadBaseControl IO m, MonadIO m) => m () -> m ThreadId | 54 | fork :: (MonadBaseControl IO m, MonadIO m) => m () -> m ThreadId |
50 | fork action = do | 55 | fork = instrumented Raw.fork |
51 | t <- Raw.fork $ do | 56 | {-# INLINE fork #-} |
57 | |||
58 | instrumented :: ( MonadBaseControl IO m | ||
59 | , MonadIO m) => | ||
60 | (m () -> m ThreadId) -> m () -> m ThreadId | ||
61 | instrumented 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)) |