Wrapped concurrentqueue + semaphore pair together for readability, an… #761
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.
…d unblocked recovery main loop during retry delay.
Proposed Changes
In the process of changing the AutorecoveringConnection to run via the TPL versus having its own dedicated thread I noticed that the Task.Delay operations for recovery retries were being awaited. My expectation with the RecoveryLoop was that it would be able to process commands that came in during the delay, which it cannot do if it's awaiting the delay inside of a command handler.
I also think that if we're awaiting a Task.Delay without passing it a cancellation token then we won't be able to easily cancel out of an auto-recovering connection that's in a Delay, it will instead timeout in StopRecoveryLoop if RequestConnectionTimeout is less than NetworkRecoveryInterval and log a warning. I solved this by not awaiting the Task.Delay operation, it could also be solved by passing a CancellationToken.
Also I wrapped the semaphore and concurrentqueue together in a class to clarify that they were acting together (i.e. Enqueue should be followed by semaphore.Release()). This improved the readability in my opinion, but I'd be happy to take this part out if it's not popular.
Types of Changes
What types of changes does your code introduce to this project?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creatingthe PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.
CONTRIBUTING.md
documentFurther Comments
This is an identical copy of #752 , I just squashed the 6 commits to one to make it less noisy. Feel free to dismiss this or the other one to get the count back to one. I also updated to a personal fork instead of one in my organization, to see if that made it possible for others to push changes. @lukebakken