transient-haskell / transient

A full stack, reactive architecture for general purpose programming. Algebraic and monadically composable primitives for concurrency, parallelism, event handling, transactions, multithreading, Web, and distributed computing with complete de-inversion of control (No callbacks, no blocking, pure state)
MIT License
633 stars 28 forks source link

Use raw fork instead of forkIO #64

Open harendra-kumar opened 7 years ago

harendra-kumar commented 7 years ago

Since we create threads quite often it may be helpful to use raw fork instead of forkIO. Something like this:

-- 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
rawForkIO action = IO $ \ s ->
   case (fork# action s) of (# s1, tid #) -> (# s1, ThreadId tid #)
agocorona commented 7 years ago

If this is faster, It would be worth the pain