Add safe retrying, deadline-bounded CV read/write#7
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds
asyncCV operations that take a caller timeout and either return the result or throw — no manual event correlation.API
IProgrammingControl(neutral, programming track):Task<byte> ReadCvAsync(cv, timeout),Task WriteCvAsync(cv, value, timeout).IZ21CommandStation(Z21/POM):Task<byte> ReadPomCvAsync(loco, cv, timeout),Task WritePomCvAsync(loco, cv, value, timeout).CvOperationTimeoutException,CvShortCircuitException.The existing fire-and-forget
ReadCvAsync(cv)/WriteCvAsync(cv, value)+ event methods are unchanged.Behaviour
LAN_X_CV_NACKarrives — no fixed interval.LAN_X_CV_NACK_SC) aborts immediately withCvShortCircuitException(no retry).CvOperationTimeoutException.LAN_X_CV_RESULT(genuine decoder ACK) — no read-back.SemaphoreSlimbecauseNACK/NACK_SCcarry no CV address.Notes
CV_RESULT= "finished", not "succeeded"; don't interleave the safe and fire-and-forget CV methods concurrently.Z21CommandStation.Disposenow also disposes theSemaphoreSlim(overlaps theDisposeedit in the DI-fixes PR — trivial rebase).Tests
12 new
FakeTransport-driven tests (result / retry-on-NACK / short-circuit / timeout for read, write, POM read, POM write incl. read-back mismatch retry), written test-first. Full suite green: Z21.Client 665.