Add availability-polling + logging, and cleanup backend - #4
Open
deathvelt wants to merge 1 commit into
Open
Conversation
… and synchronize with a lock
deathvelt
force-pushed
the
prism-integration
branch
from
September 3, 2026 13:08
6749e61 to
2684bc0
Compare
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.
#2. General refactors.
These are all a lot of refactors, so this PR is bigger than usual.
backend Feature:
This was overhauled to be sleaker. It is now an enum, with 28 values only. You can check if a feature is supported using
The reason is that the old code was already very hard to maintain because there were multiple places in which the full set of 28 enum values were repeated.
BackendId:
This was made into a record with the default prism backend IDs as static constants. We can allow for any backend ID hash to be represented now where as before, we could not.
Logging:
Logging should be bound and hookable, now. It has been tested and found working. You can set listeners to pipe the output to your client's logger, determine which severity should be logged, etcetera.
Prism exception and prism error:
PrismError is now an enum. Each enum value references one of the exception classes in PrismException. Thus, the throwIfError method was heavily simplified.
Context:
Availability polling is now supported. Its values are available on context, and there is now a builder to construct the context with whatever values for PollInterval/Debounce/AutoPowerManagement/BackoffMaxMs, as well as the other functions like pause and resume availability polling.
From what tests were committed on a live instance of MC with this library, this seemed to work well enough, with repeated restarting of NVDA and a few other scenarios.
Context also now has getRegisteredBackends() to get all the backends registered with prism.
Backend:
close always frees now, as per prism convention. The owned flag was removed because it prevented the context from acquiring a better backend when availability changed due to not freeing if it was false.
A lot of the boilerplate was simplified by wrapping. locked() performs the operations of checking if closed + synchronized with the lock. OutCall is a functional interface which is used to get the resulting out values from a call, etcetera.
The backend is also now synchronized with a lock since prism docs state that backend instances are not thread-safe.