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

Add Task.Options with an autoCancelableRunLoops property #226

Closed
alexandru opened this issue Sep 27, 2016 · 0 comments
Closed

Add Task.Options with an autoCancelableRunLoops property #226

alexandru opened this issue Sep 27, 2016 · 0 comments
Assignees
Milestone

Comments

@alexandru
Copy link
Member

alexandru commented Sep 27, 2016

The Task run-loop needs to be customizable with a Task.Options case class that gets instantiated on runAsync to a Task.defaultOptions and then passed along in task implementations.

Task then can provide a helper such as executeWithOptions(f: Options => Options), such that we can then do:

source.executeWithOptions(_.enableAutoCancelableRunLoops)

The problem we are trying to solve is that there are certain instances in which Task.flatMap loops are better off not being automatically cancelable. Such a use-case has been discovered in the monix-kafka project, where we could get rid of synchronize on cancelation if flatMap-loops wouldn't automatically cancel.

Of course, in that case it is debatable whether getting rid of synchronization buys us anything. But it's certainly a valid use-case showing how in certain cases we are forced to synchronize and trigger an immediate cancelation precisely because later we might not get the chance.

Having Task.flatMap loops be auto-cancelable by default is also error-prone. It would be better if Task.flatMap wouldn't be auto-cancelable by default, with an option to turn this behavior on where needed.

@alexandru alexandru added this to the 2.1.0 milestone Sep 27, 2016
@alexandru alexandru self-assigned this Oct 9, 2016
@alexandru alexandru changed the title Add ExecutionModel#autoCancelableLoops property (Maybe) Add Task.Options with an autoCancelableRunLoops property Oct 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant