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

evalOnExecutor #3691

Merged
merged 4 commits into from
Jul 9, 2023
Merged

evalOnExecutor #3691

merged 4 commits into from
Jul 9, 2023

Conversation

homycdev
Copy link
Contributor

No description provided.

@homycdev
Copy link
Contributor Author

@armanbilge @durban I do apologise for creating new branch. I somehow messed up the previous branch, so i decided to create new one. Hope for your understanding!

@durban
Copy link
Contributor

durban commented Jun 14, 2023

@homycdev It's not a big problem. Btw, you don't have to merge into your PR (I think I've seen you do that on the other one), you can just push to the branch (homycdev:evalOnExecutor in this case). I'll re-review this when it is green (there seems to be a scalafix problem).

Comment on lines 363 to 366
* Shifts the execution of the current IO to the specified [[java.util.concurrent.Executor]].
*
* @param executor
* @return
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Shifts the execution of the current IO to the specified [[java.util.concurrent.Executor]].
*
* @param executor
* @return
* Shifts the execution of the current IO to the specified [[java.util.concurrent.Executor]].
*
* @see [[evalOn]]

Comment on lines 368 to 380
def evalOnExecutor(executor: Executor): IO[A] = {
require(executor != null, "Cannot pass undefined Executor as an argument")
executor match {
case ec: ExecutionContext =>
evalOn(ec: ExecutionContext)
case executor =>
IO.executionContext.flatMap { refEc =>
val newEc: ExecutionContext =
ExecutionContext.fromExecutor(executor, refEc.reportFailure)
evalOn(newEc)
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Instead of duplicating the implementation :)

Suggested change
def evalOnExecutor(executor: Executor): IO[A] = {
require(executor != null, "Cannot pass undefined Executor as an argument")
executor match {
case ec: ExecutionContext =>
evalOn(ec: ExecutionContext)
case executor =>
IO.executionContext.flatMap { refEc =>
val newEc: ExecutionContext =
ExecutionContext.fromExecutor(executor, refEc.reportFailure)
evalOn(newEc)
}
}
}
def evalOnExecutor(executor: Executor): IO[A] =
IO.asyncForIO.evalOnExecutor(executor)

Copy link
Contributor

@durban durban left a comment

Choose a reason for hiding this comment

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

I've left a few nitpicking comments, otherwise seems good to me.

core/shared/src/main/scala/cats/effect/IO.scala Outdated Show resolved Hide resolved
core/shared/src/main/scala/cats/effect/IO.scala Outdated Show resolved Hide resolved
Copy link
Contributor

@durban durban left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

@durban
Copy link
Contributor

durban commented Jul 5, 2023

The CI failure seems unrelated, I've restarted it.

@homycdev homycdev requested a review from armanbilge July 6, 2023 08:18
@durban
Copy link
Contributor

durban commented Jul 9, 2023

@armanbilge Do you want to take another look at this, or should I just merge it?

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.

Thanks for all your work on this!

@armanbilge armanbilge linked an issue Jul 9, 2023 that may be closed by this pull request
@durban
Copy link
Contributor

durban commented Jul 9, 2023

@homycdev Thank you for your contribution!

@durban durban merged commit 93518d4 into typelevel:series/3.x Jul 9, 2023
43 checks passed
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.

Add Async#evalOn(executor) or Async#evalOnExecutor(executor)
3 participants