Task Cancellation #53
Task Cancellation #53
Conversation
@@ -485,6 +610,7 @@ public Void then(Task<TResult> task) { | |||
}, 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.
extra newline
Let's revert the changes in I'm not sure how I feel about Otherwise, everything is looking good! You've been making awesome contributions :) |
@grantland updated with suggested changes, will move the RE |
* <p/> | ||
* A {@code CancellationToken} can only be cancelled once - it should not be passed to future operations | ||
* once cancelled. | ||
*/ |
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.
{@link CancellationTokenSource}
{@link CancellationTokenSource#getToken()}
{@link CancellationTokenSource#cancel()}
@josephearl Thanks! I've added some doc changes and I'm planning on doing another once-over for the API and implementation, so you can wait on updating. RE AppLinkResolver - I'm not sure AppLinkResolver2 would work since we'd need to accept the base implementation in |
@grantland I think there would need to be a new
|
Re I also just noticed Please note that the following isn't about requesting things to be changed, but opening discussion: TPL defines Do we want to add Otherwise, the implementation looks great! |
OK I'll re-add
If the operation completes successfully, the listener is still registered and retaining operation (and the same token may be shared between a number of tasks). Also the cancellation token may be cancelled some time later after this operation has completed. In this case the code above still attempts to cancel the operation. To avoid this an And since the I suppose another option to the ID could be to Capture the cancellation listener so the Capture can be created before the operation.
Just to be clear on |
Re Re Adding Also, let me read into register really quick. It seems there's a bunch of complexity I didn't anticipate. |
We actually might have enough for one PR. Let's just clean up the last nits and move the other topics to their own PRs, since they don't really have any impact on any APIs or implementations from this PR. How does that sound? |
@grantland sure. I'll update the documentation add |
Looks like in C# it is the only way to create a cancelled task, so actually I don't think we need it given we already have |
I think adding a CancellableAppLinkResolver makes sense. |
@josephearl: To clarify, we're not adding |
@grantland yes I've left that out. Updated. |
* Propagates notification that operations should be canceled. | ||
* <p/> | ||
* Create an instance of {@code CancellationTokenSource} and pass the token returned from | ||
* {@code #getToken()} to the asynchronous operation(s). Call |
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.
{@link CancellationTokenSource#getToken()}
* | ||
* {@link CancellationTokenSource#getToken()} | ||
* | ||
* {@link CancellationTokenSource#cancel()} |
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.
@see CancellationTokenSource
@see CancellationTokenSource#getToken()
@see CancellationTokenSource#cancel()
Implementation looks good, just a few doc nits. I'll also assume you're adding Thanks! |
@grantland Updated docs as per your comments. Yes I will move |
Looks great, thanks! I'll look forward to the rest of it :) |
Implement task cancellation as per Task Cancellation.