-
Notifications
You must be signed in to change notification settings - Fork 530
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
evalOnExecutor
#3691
Conversation
@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! |
@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 ( |
* Shifts the execution of the current IO to the specified [[java.util.concurrent.Executor]]. | ||
* | ||
* @param executor | ||
* @return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* 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]] |
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) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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 :)
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) |
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM!
The CI failure seems unrelated, I've restarted it. |
@armanbilge Do you want to take another look at this, or should I just merge it? |
There was a problem hiding this 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!
@homycdev Thank you for your contribution! |
No description provided.