diff options
author | James Crayne <jim.crayne@gmail.com> | 2019-10-18 09:43:20 +0000 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-01 19:52:45 -0500 |
commit | 5bde2cfe951577be3018b437619cd0e87ab20096 (patch) | |
tree | 3077430f036d44d856caa3ca65e9f7644102fee5 /dht/src | |
parent | 88cb351cb6ddfb5e80f247bea6cc503ed1e12baf (diff) |
Control.Concurrent.ThreadUtil replaces #ifdef imports
* new function, forkLabeled
* new module Control.Concurrent.ThreadUtil
* label a few unlabeled threads
Diffstat (limited to 'dht/src')
-rw-r--r-- | dht/src/Control/Concurrent/ThreadUtil.hs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/dht/src/Control/Concurrent/ThreadUtil.hs b/dht/src/Control/Concurrent/ThreadUtil.hs new file mode 100644 index 00000000..2888e899 --- /dev/null +++ b/dht/src/Control/Concurrent/ThreadUtil.hs | |||
@@ -0,0 +1,24 @@ | |||
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 | #endif | ||