remove when_/unless_

This commit is contained in:
1computer1 2020-06-16 22:43:21 -04:00
parent b493eb67ed
commit 1b4d2a04e7

View file

@ -42,7 +42,7 @@ buildImage lang@Language { name, concurrent } = do
exec_ ["docker build -t ", imageName lang, " ", cs languagesDir </> cs name] exec_ ["docker build -t ", imageName lang, " ", cs languagesDir </> cs name]
setupQSems setupQSems
logInfo ["Built image ", cs $ imageName lang] logInfo ["Built image ", cs $ imageName lang]
when_ prepareContainers $ setupContainer lang when prepareContainers . void $ setupContainer lang
where where
setupQSems :: Myriad () setupQSems :: Myriad ()
setupQSems = do setupQSems = do
@ -62,7 +62,7 @@ buildAllImages = do
startCleanup :: Myriad () startCleanup :: Myriad ()
startCleanup = do startCleanup = do
Config { cleanupInterval } <- asks config Config { cleanupInterval } <- asks config
when_ (cleanupInterval > 0) $ do when (cleanupInterval > 0) . void $ do
let t = fromIntegral cleanupInterval * 60000000 let t = fromIntegral cleanupInterval * 60000000
fork $ timer t fork $ timer t
where where
@ -179,7 +179,7 @@ evalCode lang@Language { name, timeout, retries } numRetries code = withContaine
timer doneRef = do timer doneRef = do
threadDelay $ fromIntegral timeout * 1000000 threadDelay $ fromIntegral timeout * 1000000
done <- readMVar doneRef done <- readMVar doneRef
unless_ done $ do unless done . void $ do
writeMVar doneRef True writeMVar doneRef True
killContainer name killContainer name
@ -204,9 +204,3 @@ newContainerName Language { name } = do
imageName :: Language -> ImageName imageName :: Language -> ImageName
imageName Language { name } = "1computer1/comp_iler:" <> cs name imageName Language { name } = "1computer1/comp_iler:" <> cs name
when_ :: Applicative f => Bool -> f a -> f ()
when_ p = when p . void
unless_ :: Applicative f => Bool -> f a -> f ()
unless_ p = unless p . void