Check if nextEvent works as advertised

This commit is contained in:
Joscha 2020-01-07 11:54:56 +00:00
parent b7892bd139
commit 22aacc1c98

View file

@ -237,11 +237,12 @@ instance FromJSON Event where
, EventSnapshot <$> parseJSON v , EventSnapshot <$> parseJSON v
] ]
--TODO: Check if this would block infinitely if the client is stopped while this
-- waits for an event
nextEvent :: Client e Event nextEvent :: Client e Event
nextEvent = do nextEvent = do
info <- getClientInfo info <- getClientInfo
-- This appears to stop correctly when 'ciStopped' is set to True, even if
-- that happens from a different thread while this thread is waiting for the
-- event channel.
exceptionOrEvent <- liftIO $ atomically $ do exceptionOrEvent <- liftIO $ atomically $ do
stopped <- readTVar (ciStopped info) stopped <- readTVar (ciStopped info)
if stopped if stopped