mirror of
https://github.com/k-bx/par.git
synced 2024-08-16 18:50:23 +03:00
Merge pull request #8 from qrilka/fork-finally
Using forkFinally instead of fork + finally
This commit is contained in:
commit
27ee91006e
@ -21,7 +21,7 @@ import Data.Semigroup ((<>))
|
|||||||
import Data.String.Class (toStrictByteString)
|
import Data.String.Class (toStrictByteString)
|
||||||
import Options.Applicative
|
import Options.Applicative
|
||||||
import Prelude hiding (mapM, mapM_)
|
import Prelude hiding (mapM, mapM_)
|
||||||
import SlaveThread (fork)
|
import SlaveThread (fork, forkFinally)
|
||||||
import System.Exit
|
import System.Exit
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Process
|
import System.Process
|
||||||
@ -109,7 +109,7 @@ waitSignal (WaitSignal mv) = takeMVar mv >> return ()
|
|||||||
forkW :: IO a -> IO (ThreadId, WaitSignal)
|
forkW :: IO a -> IO (ThreadId, WaitSignal)
|
||||||
forkW f = do
|
forkW f = do
|
||||||
ws <- newEmptyMVar
|
ws <- newEmptyMVar
|
||||||
tid <- fork (finally f (putMVar ws True))
|
tid <- forkFinally (putMVar ws True) f
|
||||||
return (tid, WaitSignal ws)
|
return (tid, WaitSignal ws)
|
||||||
|
|
||||||
runSingle ::
|
runSingle ::
|
||||||
|
Loading…
Reference in New Issue
Block a user