-
Notifications
You must be signed in to change notification settings - Fork 744
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
Possible threading issue in FireAsync #294
Comments
It is correct the Stateless isn't designed to be thread-safe. There's note in the readme in the section about Async Triggers. The users of Stateless is responsible for assuring thread safety. |
Yes I saw the note, and it makes sense. But the issue here is inside Stateless (so caused by it own implementation), hence the user cannot do anything about this. |
If adding volatile and switching to concurrentQueue makes it slightly better, than I think I could go ahead and do that. But Stateless would still not be thread-safe, right? |
ConcurrentQueue isn't available in netStandard1.0, which Stateless uses. It is available in 1.1 and higher. Would changing to netstandard1.1 (or newer) cause any problems? @JeremyCade @nblumhardt |
I think the accepted answer to that question is wrong - (I could be mistaken, but I think the TPL Nothing to do, here. |
@nblumhardt could you note this issue on the stackoverflow thread as well? It would be nice if a memory barrier is generated. Edit: Correction; it can be accessed from multiple contexts/threads with |
Stephen Cleary also added an answer on the stackoverflow question: https://stackoverflow.com/a/54413147/2471080 . |
@denxorz I can't see what Stephen's talking about regarding
I think this sums up my understanding of it, too. |
I'm closing this, it seems the consensus is that there is no need to change InternalFireQueuedAsync. |
I was trying to figure something out related to async/await, and used a snipped of the stateless code as an example to ask a question on StackOverflow. It seems that the Stateless code might have an threading issue in the FireAsync. The
_firing
field should be protected by a memory barrier to make sure it is synched after having a continuation, which can happen on a ThreadPool thread.See this answer for more info: https://stackoverflow.com/a/53649830/2471080
Best regards,
Dennis
The text was updated successfully, but these errors were encountered: