diff options
Diffstat (limited to 'lifted-concurrent/src/Control/Concurrent/ThreadUtil.hs')
-rw-r--r-- | lifted-concurrent/src/Control/Concurrent/ThreadUtil.hs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lifted-concurrent/src/Control/Concurrent/ThreadUtil.hs b/lifted-concurrent/src/Control/Concurrent/ThreadUtil.hs new file mode 100644 index 00000000..a258d933 --- /dev/null +++ b/lifted-concurrent/src/Control/Concurrent/ThreadUtil.hs | |||
@@ -0,0 +1,31 @@ | |||
1 | {-# LANGUAGE CPP #-} | ||
2 | module Control.Concurrent.ThreadUtil | ||
3 | ( | ||
4 | #ifdef THREAD_DEBUG | ||
5 | module Control.Concurrent.Lifted.Instrument | ||
6 | #else | ||
7 | module Control.Control.Lifted | ||
8 | , module GHC.Conc | ||
9 | #endif | ||
10 | ) where | ||
11 | |||
12 | #ifdef THREAD_DEBUG | ||
13 | import Control.Concurrent.Lifted.Instrument | ||
14 | #else | ||
15 | import Control.Concurrent.Lifted | ||
16 | import GHC.Conc (labelThread) | ||
17 | |||
18 | forkLabeled :: String -> IO () -> IO ThreadId | ||
19 | forkLabeled lbl action = do | ||
20 | t <- forkIO action | ||
21 | labelThread t lbl | ||
22 | return t | ||
23 | {-# INLINE forkLabeled #-} | ||
24 | |||
25 | forkOSLabeled :: String -> IO () -> IO ThreadId | ||
26 | forkOSLabeled lbl action = do | ||
27 | t <- forkOS action | ||
28 | labelThread t lbl | ||
29 | return t | ||
30 | {-# INLINE forkOSLabeled #-} | ||
31 | #endif | ||