Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backpressure Interface for CE3 #1817

Merged
merged 2 commits into from
Jul 26, 2021
Merged

Conversation

etspaceman
Copy link
Contributor

Created per the discussion on #1695 (comment)

*/
def apply[F[_]](
strategy: Strategy,
bound: Int
Copy link
Member

Choose a reason for hiding this comment

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

Since this is passed to the underlying semaphore, which accepts Long arguments, should we maybe have this be a Long too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Potentially, though the CE2 version uses an Int. Also, Long would be quite a large bound for what Backpressure is; Long.MaxValue would be a heck of a lot of concurrent effects 😅

Copy link
Member

Choose a reason for hiding this comment

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

I agree. I was just raising a question on the API design. I'm fine either way.

@vasilmkd
Copy link
Member

vasilmkd commented May 8, 2021

Any objections here? I'd be happy to see this merged.

strategy: Strategy,
bound: Int
)(implicit GC: GenConcurrent[F, Throwable]): F[Backpressure[F]] = {
require(bound > 0)
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to raise than throw here? I'm surprised to find require in the code in a couple places, so there is precedent for this.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah... these instances exist because of the GenConcurrent constraint...

.tryAcquire
.bracket {
case true => f.map(_.some)
case false => none[A].pure[F]
Copy link
Member

Choose a reason for hiding this comment

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

Could cache this value so it doesn't need to be recreated on every backpressured call, at the expense of always creating it once.

@vasilmkd vasilmkd added this to the 3.2.0 milestone Jun 18, 2021
Copy link
Member

@armanbilge armanbilge left a comment

Choose a reason for hiding this comment

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

Cool!! Can we add syntax for this? Like I just proposed for Supervisor in #2068.

@djspiewak djspiewak removed this from the 3.2.0 milestone Jul 16, 2021
@kubukoz
Copy link
Member

kubukoz commented Jul 26, 2021

@armanbilge if you're up for it, feel free to make the PR :) I'll merge for now to avoid delaying further (we're already past 3.2.0 though)

@kubukoz kubukoz merged commit 07d1828 into typelevel:series/3.x Jul 26, 2021
@etspaceman etspaceman deleted the backpressure branch July 26, 2021 18:46
@vasilmkd
Copy link
Member

@djspiewak I guess the we're shipping this?

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.

6 participants