-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Misusage of TaskContinuationOptions.AttachedToParent can cause unexpected behavior #1346
Comments
@JeffCyr thanks for pointing this out - going to run an experiment with this real quick. I put the flags on there when we had an issue with Akka.Remote where a detached child task wasn't being processed in a manner consistent with the expected handshake procedure |
That was a long time ago though - back in early 2014. |
Aaronontheweb
added a commit
to Aaronontheweb/akka.net
that referenced
this issue
Oct 2, 2015
Aaronontheweb
added a commit
to Aaronontheweb/akka.net
that referenced
this issue
Dec 5, 2015
Aaronontheweb
added a commit
to Aaronontheweb/akka.net
that referenced
this issue
Dec 8, 2015
Aaronontheweb
added a commit
to Aaronontheweb/akka.net
that referenced
this issue
Dec 8, 2015
…kkadotnet#1346 cleanedup other TPL usages fixed Ask bugs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have seen multiple usage of TaskContinuationOptions.AttachedToParent while exploring the codebase and I think it can be harmful in some cases.
Take this for example:
In the code above, specifying AttachedToParent has nothing to do with
taskToPipe
, what it really does is attaching to the currently executing Task (if the task was not scheduled with DenyChildAttach options). The flag does nothing if there is no current task.Here is a code sample to demonstrate the consequences:
The nasty consequence is that if you call PipeTo inside a Task, this task will not complete until the PipeTo Task completes. Note that Tasks scheduled by Task.Run are immune to this because it uses the DenyChildAttach flag.
I was confused when I did not repro the behavior simply by calling Ask because it use a TaskCompletionSource declared like this:
I then realized that there is no such constructor taking a TaskContinuationOptions, only one accepting TaskCreationOptions, so the compiler choose the ctor taking
object state
:)I have never experienced the need of using the AttachedToParent flag, it could be used for complex parent/child task coordination, but there is often a simpler way than using AttachedToParent.
The text was updated successfully, but these errors were encountered: