module Arbiter.Worker.WorkerState
( WorkerState (..)
, isShuttingDown
) where
import UnliftIO.STM (STM, TVar, readTVar)
data WorkerState
=
Running
|
Paused
|
ShuttingDown
deriving stock (WorkerState -> WorkerState -> Bool
(WorkerState -> WorkerState -> Bool)
-> (WorkerState -> WorkerState -> Bool) -> Eq WorkerState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: WorkerState -> WorkerState -> Bool
== :: WorkerState -> WorkerState -> Bool
$c/= :: WorkerState -> WorkerState -> Bool
/= :: WorkerState -> WorkerState -> Bool
Eq, Int -> WorkerState -> ShowS
[WorkerState] -> ShowS
WorkerState -> String
(Int -> WorkerState -> ShowS)
-> (WorkerState -> String)
-> ([WorkerState] -> ShowS)
-> Show WorkerState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WorkerState -> ShowS
showsPrec :: Int -> WorkerState -> ShowS
$cshow :: WorkerState -> String
show :: WorkerState -> String
$cshowList :: [WorkerState] -> ShowS
showList :: [WorkerState] -> ShowS
Show)
isShuttingDown :: TVar WorkerState -> STM Bool
isShuttingDown :: TVar WorkerState -> STM Bool
isShuttingDown TVar WorkerState
stateVar = (WorkerState -> WorkerState -> Bool
forall a. Eq a => a -> a -> Bool
== WorkerState
ShuttingDown) (WorkerState -> Bool) -> STM WorkerState -> STM Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TVar WorkerState -> STM WorkerState
forall a. TVar a -> STM a
readTVar TVar WorkerState
stateVar