Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

Currently, the takeBetween operator on ZQueue starts out by calling takeUpTo, which has an optimized implementation that attempts to immediately take the specified number of elements from the underlying queue. However, if the elements are not immediately available we fall back to repeatedly taking individual elements from the queue. This causes us to lose the benefits of taking multiple elements at once if they are not immediately available.

This PR change the implementation of takeBetween to call take once if additional elements are required to suspend until new elements are available but then to recursively call takeBetween to attempt to take multiple queue elements again in case more elements are available by the time we resume.

@adamgfraser adamgfraser requested review from iravid and jdegoes January 23, 2021 15:16
iravid
iravid previously approved these changes Jan 24, 2021
Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

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

Very nice 👍

@adamgfraser adamgfraser merged commit 13ec4d9 into zio:master Jan 24, 2021
@adamgfraser adamgfraser deleted the takebetween branch January 24, 2021 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants