Skip to content

Instantly share code, notes, and snippets.

@lehins
Created July 17, 2019 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lehins/3653b53a6ace028bf0158c53294145f3 to your computer and use it in GitHub Desktop.
Save lehins/3653b53a6ace028bf0158c53294145f3 to your computer and use it in GitHub Desktop.
name <- atomically $ do
readTVar (currentUpdate ctxt) >>= \case
name:names <- readTVar (queuedUpdates ctxt)
writeTVar (queuedUpdates ctxt) names
return name
name <- atomically $ do
readTVar (currentUpdate ctxt) >>= \case
Just _ -> retry
Nothing -> readTVar (queuedUpdates ctxt) >>= \case
[] -> retry
(name:names) -> do
writeTVar (queuedUpdates ctxt) names
return name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment