Expose more ThreadPool
functionality through Future.withEventualValue()
.
#1828
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously,
Future.withEventualValue()
tried to match theFuture
constructor, with one subtle difference in behavior. It interpreted null to mean "run the function again," which causes an infinite loop if the programmer returns null without realizing. Joshua found a regression of this sort in Lime itself, one I should have caught but overlooked.This PR changes the function signature to avoid any possibility of this error. There is no return value anymore, so you can't accidentally return the wrong value. Instead, as with
ThreadPool
, you are given aWorkOutput
object and must callsendComplete()
at some point. The work function has the same signature as inThreadPool
, so if users understand the one, they'll understand the other.I have a couple other branches that are closer to how
withEventualValue()
used to work, and I can bring them back if requested. ButwithEventualValue()
is new in 8.2.0, so it shouldn't hurt to change its signature.