Decouple BgThread from braille module (PR #14312)
Closes #14130
Related to #14147
Summary:
#14130 notes that the background thread for i/o is too tightly coupled too the braille module.
This required the hwIo module to queue an APC to the braille background thread.
User facing changes:
None, apart from more safety checks that might impose stability improvements.
Changes:
1. Moved the background thread from the braille module.
- Instead make it a class on the hwIo module.
- It is also no longer a singleton and therefore add-ons can create their own i/o thread.
2. The APC queue function now takes a callable or lambda.
- Rather than all cases where APCs have to be queued to the background thread being responsible for wrapping themselves in a winKernel.PAPCFUNC.
- The provided callable is converted to an APC when queued.
- There is a cache on the thread class to keep references to wrapped APCs until they are finished.
- The wrapper also ensures that the APC doesn't execute when the thread is about to exit.
3. hwIo.base.IoBase now contains a new `_initialRead` method that initiates reading on the background thread.
- This method can be overridden on subclasses to outsource the reading to another thread.