Skip to content

Private io and handles - #2

Draft
veloce wants to merge 6 commits into
masterfrom
private_io_and_handles
Draft

Private io and handles#2
veloce wants to merge 6 commits into
masterfrom
private_io_and_handles

Conversation

@veloce

@veloce veloce commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

veloce and others added 6 commits August 25, 2026 12:06
Four fixes to the output path, ported from dart-multistockfish.

Reads take a page rather than 255 bytes, and the reader isolate sends
lines to the handle in one message per chunk instead of one per line. A
reader that cannot keep up fills the pipe, and the engine then blocks in
write() inside its UCI loop, where it answers nothing -- `quit` included.

The quit marker is recognised as a suffix rather than by matching the
whole buffer. A page-sized read usually picks it up in the same call as
the output written before it, and a reader that misses it never returns:
it stays blocked on the pipe and becomes a second reader on the next
engine's output. A marker split across two reads is carried over.

Chunks are decoded with allowMalformed rather than toDartString(), which
throws on a partial UTF-8 sequence. A chunk is a slice of a byte stream,
so a multi-byte character can straddle two of them, and the throw would
land in the reader isolate's loop and kill the only thing draining the
pipe.

Teardown waits for the reader to let go of the pipe before it returns.
init() drains the pipe before starting an engine, and a drain that beats
the reader to the marker strands it. Relatedly, _RunningEngine.exited is
now completed only by a real exit code from the main isolate; dispose()
is renamed detach() to say what it does.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FuSuWcxTxWr8Pv8WZhX3SW
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