How do you subscribe to state changes across threads?
How do you subscribe to state changes across threads? How do you conditionally wrap an IO action in a given thread depending on some mutable state stored in an MVar? My overall aim is to enable timeouts so that in a given game if a player does not send an action to the server within 30 seconds then the socket msg callback will be called with a special Timeout action to denote failure of the player to act. I am looking for a method to enable each socket thread to subscribe to a change in game state contained in an MVar. My current draft implementation for creating a Timeout action is as follows: -- This function processes msgs from authenticated clients authenticatedMsgLoop :: (MsgIn -> ReaderT MsgHandlerConfig (ExceptT Err IO) ()) -> MsgHandlerConfig -> IO () authenticatedMsgLoop msgCallback msgHandlerConfig@MsgHandlerConfig {..} = do finally (forever $ do maybeMsg <- timeout 1000000 (WS.receiveData clientConn) let parsedMsg = maybe (J...