Skip to content

Add AsyncConnector and non-blocking background connection - #978

Merged
PCMan merged 2 commits into
masterfrom
feature-async-connection
Oct 21, 2026
Merged

PCMan merged 2 commits into
masterfrom
feature-async-connection

Conversation

@PCMan

@PCMan PCMan commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

This PR builds on top of #979 (refactor/rpc-pipe) to move pipe connection and initialization off the host UI thread:

  • AsyncConnector background threadpool: Performs pipe connection and the init RPC handshake asynchronously using the Windows Threadpool API to eliminate UI freezes during IME activation. Completion is safely marshaled to the host UI thread via a hidden message-only window and WM_PIME_ASYNC_DONE.
  • Threadpool module refcount: Properly balances the DLL reference count with FreeLibraryWhenCallbackReturns to eliminate fast-fail crashes (0xc0000409) on module unload in arbitrary host processes.
  • Client::State lifecycle: Introduces an explicit Client::State enum (Disconnected, Connecting, Ready) to manage connection states cleanly without ambiguous flag combinations.
  • Auto-reconnection: Implements ensureConnected() to automatically trigger asynchronous reconnection upon user input if the backend was restarting or down during IME activation.

Generated with assistance from Google Antigravity (Gemini 3.8 Flash).

@PCMan
PCMan force-pushed the feature-async-connection branch from 2829710 to 0fee870 Compare October 21, 2026 07:10
@PCMan PCMan changed the title Make backend pipe connection and init handshake asynchronous Add AsyncConnector and non-blocking background connection Oct 21, 2026
@PCMan
PCMan changed the base branch from master to refactor/rpc-pipe October 21, 2026 07:10
Base automatically changed from refactor/rpc-pipe to master October 21, 2026 07:13
PCMan added 2 commits October 21, 2026 00:14
Implement asynchronous pipe connection and init RPC execution using the Windows Threadpool API to eliminate host UI freezes during IME activation.
Marshal completion callbacks safely back to the host UI thread via a hidden message-only window and WM_PIME_ASYNC_DONE.
Increment DLL reference count during threadpool task execution so FreeLibraryWhenCallbackReturns safely balances the module reference count without premature DLL unloading.
Use non-throwing JSON parsing and cancellable retry intervals between connection attempts.

Generated with assistance from Google Antigravity (Gemini 3.8 Flash)
…ction

Replace synchronous named pipe connection and blocking init handshake with AsyncConnector and RpcPipe.
Introduce Client::State enum (Disconnected, Connecting, Ready) to cleanly track connection lifecycle and eliminate ambiguous state combinations.
Implement Client::ensureConnected() to automatically trigger asynchronous reconnection on user interaction if connection was lost or started while PIMELauncher was down.
Replace throwing json::parse and try/catch blocks with parseJsonNoThrow and jsonValueOr for SEH safety in arbitrary host applications.

Generated with assistance from Google Antigravity (Gemini 3.8 Flash)
@PCMan
PCMan force-pushed the feature-async-connection branch from 0fee870 to 6f9d5b3 Compare October 21, 2026 07:15
@PCMan PCMan self-assigned this Oct 21, 2026
@PCMan
PCMan merged commit e0ddf2f into master Oct 21, 2026
4 of 6 checks passed
@PCMan
PCMan deleted the feature-async-connection branch October 21, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant