Skip to content
Snippets Groups Projects
Commit 43f94885 authored by Jens Nolte's avatar Jens Nolte
Browse files

Move 'installSignalHandlers' into 'BarIO' monad

parent 25b32f0f
No related branches found
No related tags found
No related merge requests found
...@@ -147,13 +147,15 @@ handleStdin options actionListIORef = do ...@@ -147,13 +147,15 @@ handleStdin options actionListIORef = do
| C8.last line == ',' = C8.init line | C8.last line == ',' = C8.init line
| otherwise = line | otherwise = line
installSignalHandlers :: BarUpdateChannel -> IO () installSignalHandlers :: BarIO ()
installSignalHandlers barUpdateChannel = void $ installHandler sigCONT (Catch sigContAction) Nothing installSignalHandlers = do
bar <- ask
liftIO $ void $ installHandler sigCONT (Catch (sigContAction bar)) Nothing
where where
sigContAction :: IO () sigContAction :: Bar -> IO ()
sigContAction = do sigContAction bar = do
hPutStrLn stderr "SIGCONT received" hPutStrLn stderr "SIGCONT received"
updateBar' barUpdateChannel updateBar'' bar
runBarConfiguration :: BarIO () -> MainOptions -> IO () runBarConfiguration :: BarIO () -> MainOptions -> IO ()
runBarConfiguration generateBarConfig options = do runBarConfiguration generateBarConfig options = do
...@@ -171,8 +173,6 @@ runBarConfiguration generateBarConfig options = do ...@@ -171,8 +173,6 @@ runBarConfiguration generateBarConfig options = do
let initialBlocks' = if indicator options then initialBlocks <> [createBlock "*"] else initialBlocks let initialBlocks' = if indicator options then initialBlocks <> [createBlock "*"] else initialBlocks
(requestBarUpdate, barUpdateEvent) <- createBarUpdateChannel (requestBarUpdate, barUpdateEvent) <- createBarUpdateChannel
-- TODO: should be removed
let barUpdateChannel = BarUpdateChannel requestBarUpdate
-- Create channel to send new block producers to render loop -- Create channel to send new block producers to render loop
newBlockChan <- newTChanIO newBlockChan <- newTChanIO
...@@ -197,7 +197,7 @@ runBarConfiguration generateBarConfig options = do ...@@ -197,7 +197,7 @@ runBarConfiguration generateBarConfig options = do
runReaderT loadBlocks bar runReaderT loadBlocks bar
-- Install signal handler for SIGCONT -- Install signal handler for SIGCONT
installSignalHandlers barUpdateChannel runReaderT installSignalHandlers bar
-- Create control socket -- Create control socket
commandChan <- createCommandChan commandChan <- createCommandChan
...@@ -210,7 +210,7 @@ runBarConfiguration generateBarConfig options = do ...@@ -210,7 +210,7 @@ runBarConfiguration generateBarConfig options = do
case command of case command of
SetFilter blockFilter -> atomicWriteIORef activeFilter blockFilter SetFilter blockFilter -> atomicWriteIORef activeFilter blockFilter
Block -> error "TODO" Block -> error "TODO"
updateBar' barUpdateChannel updateBar'' bar
link socketUpdateAsync link socketUpdateAsync
runReaderT (renderLoop options handle barUpdateEvent initialOutput newBlockChan) bar runReaderT (renderLoop options handle barUpdateEvent initialOutput newBlockChan) bar
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment