mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-08-16 08:10:55 +03:00
Move thread management to app wrapper
Why? ==== With multiple calls to `parallel`, `stopGlobalPool` stops working correctly. This moves `stopGlobalPool` higher up, and executes it once, allowing multiple calls to `parallel` to happen without causing issues.
This commit is contained in:
parent
a5b8f31e4d
commit
a6e926e4d2
@ -25,6 +25,6 @@ progressWithIndicator f i terms = do
|
||||
printPrefix i
|
||||
(tid, indicator) <- start i $ length terms
|
||||
installChildInterruptHandler tid
|
||||
mconcat <$> parallel (ioOps indicator) <* stop indicator <* stopGlobalPool
|
||||
mconcat <$> parallel (ioOps indicator) <* stop indicator
|
||||
where
|
||||
ioOps i' = map (\t -> f t <* increment i') terms
|
||||
|
@ -5,6 +5,7 @@ module Unused.CLI.Util
|
||||
, module System.Console.ANSI
|
||||
) where
|
||||
|
||||
import Control.Concurrent.ParallelIO
|
||||
import Control.Monad (void)
|
||||
import System.Console.ANSI
|
||||
import System.IO (hSetBuffering, BufferMode(NoBuffering), stdout)
|
||||
@ -16,7 +17,7 @@ import System.Exit (ExitCode(ExitFailure))
|
||||
withRuntime :: IO a -> IO a
|
||||
withRuntime a = do
|
||||
hSetBuffering stdout NoBuffering
|
||||
withInterruptHandler $ withoutCursor a
|
||||
withInterruptHandler $ withoutCursor a <* stopGlobalPool
|
||||
|
||||
resetScreen :: IO ()
|
||||
resetScreen = do
|
||||
|
Loading…
Reference in New Issue
Block a user