File: Raw.hs

package info (click to toggle)
haskell-threads 0.5.1.8-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 88 kB
  • sloc: haskell: 362; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 938 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, UnboxedTuples #-}

module Control.Concurrent.Raw ( rawForkIO, rawForkOn ) where

import Data.Function ( ($) )
import GHC.IO        ( IO(IO) )
import GHC.Exts      ( Int(I#), fork#, forkOn# )
import GHC.Conc      ( ThreadId(ThreadId) )

-- A version of forkIO that does not include the outer exception
-- handler: saves a bit of time when we will be installing our own
-- exception handler.
{-# INLINE rawForkIO #-}
rawForkIO :: IO () -> IO ThreadId
#if MIN_VERSION_base(4,17,0)
rawForkIO (IO action) = IO $ \s ->
#else
rawForkIO action = IO $ \s ->
#endif
   case (fork# action s) of (# s1, tid #) -> (# s1, ThreadId tid #)

{-# INLINE rawForkOn #-}
rawForkOn :: Int -> IO () -> IO ThreadId
#if MIN_VERSION_base(4,17,0)
rawForkOn (I# cpu) (IO action) = IO $ \s ->
#else
rawForkOn (I# cpu) action = IO $ \s ->
#endif
   case (forkOn# cpu action s) of (# s1, tid #) -> (# s1, ThreadId tid #)