summaryrefslogtreecommitdiff
path: root/Omni/Log
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-11-14 13:38:28 -0500
committerBen Sima <ben@bsima.me>2025-11-14 13:38:28 -0500
commit6e9f06455b04e2110bb14eb2c84689cef62ed856 (patch)
tree5880c4695b60ef19c2fa6e8d3169a3983158f045 /Omni/Log
parent4c4dc3a991ffde0aa821f8669024787fb65635ba (diff)
Thread LineManager through build functions
- Reserve line for each concurrent build - Release line on completion with success/failed state - Fix hlint eta reduce warning Task: t-1a1E3j1
Diffstat (limited to 'Omni/Log')
-rw-r--r--Omni/Log/Concurrent.hs22
1 files changed, 11 insertions, 11 deletions
diff --git a/Omni/Log/Concurrent.hs b/Omni/Log/Concurrent.hs
index 2a46df5..5187367 100644
--- a/Omni/Log/Concurrent.hs
+++ b/Omni/Log/Concurrent.hs
@@ -88,13 +88,13 @@ reserveLine LineManager {..} ns =
if not lmSupportsANSI
then pure Nothing
else
- atomicModifyIORef' lmLines <| \lines ->
- case findFirstFree lines of
- Nothing -> (lines, Nothing)
+ atomicModifyIORef' lmLines <| \linesMap ->
+ case findFirstFree linesMap of
+ Nothing -> (linesMap, Nothing)
Just lineNum ->
let status = BuildStatus ns "" Building
- lines' = Map.insert lineNum (Just status) lines
- in (lines', Just lineNum)
+ linesMap' = Map.insert lineNum (Just status) linesMap
+ in (linesMap', Just lineNum)
where
findFirstFree :: Map Int (Maybe BuildStatus) -> Maybe Int
findFirstFree m =
@@ -127,16 +127,16 @@ updateLine LineManager {..} mLineNum ns output =
ANSI.hRestoreCursor IO.stderr
- modifyIORef' lmLines <| \lines ->
- Map.adjust (fmap (\bs -> bs {bsLastOutput = output})) lineNum lines
+ modifyIORef' lmLines <| \linesMap ->
+ Map.adjust (fmap (\bs -> bs {bsLastOutput = output})) lineNum linesMap
releaseLine :: LineManager -> Maybe Int -> BuildState -> IO ()
-releaseLine LineManager {..} mLineNum state =
+releaseLine LineManager {..} mLineNum buildState =
case mLineNum of
Nothing -> pure ()
Just lineNum -> do
- modifyIORef' lmLines <| \lines ->
- Map.insert lineNum Nothing lines
+ modifyIORef' lmLines <| \linesMap ->
+ Map.insert lineNum Nothing linesMap
when lmSupportsANSI <| do
current <- readIORef lmCurrentLine
@@ -145,7 +145,7 @@ releaseLine LineManager {..} mLineNum state =
ANSI.hCursorUp IO.stderr (current - lineNum)
ANSI.hClearLine IO.stderr
- let statusChar = case state of
+ let statusChar = case buildState of
Success -> "✓"
Failed -> "✗"
Building -> "…"