Skip to content

Add flushTQueue, flushTBQueue - #1

Merged
hvr merged 1 commit into
haskell:masterfrom
mitchellwrosen:master
Dec 27, 2017
Merged

hvr merged 1 commit into
haskell:masterfrom
mitchellwrosen:master

Conversation

@mitchellwrosen

Copy link
Copy Markdown
Contributor

Here's a convenience function I've wanted before in the past, and it's much more efficient than:

flushTQueue :: TQueue a -> STM [a]
flushTQueue xs = do
  mx <- tryReadTQueue xs
  case mx of
    Nothing -> return []
    Just x -> fmap (x:) (flushTQueue xs)

Thanks!

@bgamari bgamari left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; just needs @since annotations. I think the next release will be 2.5.0.0.

tryReadTBQueue c = fmap Just (readTBQueue c) `orElse` return Nothing

-- | Efficiently read the entire contents of a 'TBQueue' into a list. This
-- function never retries.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a @since here?

tryReadTQueue c = fmap Just (readTQueue c) `orElse` return Nothing

-- | Efficiently read the entire contents of a 'TQueue' into a list. This
-- function never retries.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @since

@mitchellwrosen

Copy link
Copy Markdown
Contributor Author

Oops! Somehow this escaped my notifications queue. Ok, added @sinces.

@hvr

hvr commented Dec 1, 2017

Copy link
Copy Markdown
Member

@bgamari btw, what's the change that makes you think the next version needs to be a major bumped 2.5?

@mitchellwrosen

mitchellwrosen commented Dec 8, 2017 •

Copy link
Copy Markdown
Contributor Author

Indeed, if these functions are all that's making it into the release, it would be a minor version bump and I'm happy to change the annotations to 2.4.5. Anywho, is there anything else I can do to get this merged? @bgamari @hvr Thank you!

@hvr

hvr commented Dec 9, 2017

Copy link
Copy Markdown
Member

@mitchellwrosen just fill in @since TBD or something; I'll review the API changes when I make the stm release anyway to make sure @since annotation & changelog lines up. Also please change the changelog entry's version to TBD to remind me that I need to examine which kind of bump to perform.

@mitchellwrosen

Copy link
Copy Markdown
Contributor Author

@hvr Sure, done

@hvr
hvr merged commit 854a938 into haskell:master Dec 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants