stream: Support cancellation of in-flight uv_write requests
Use the new libuv write-cancellation API to make blocked stream writes
cancellable. `uv_write` now registers the stream as the writing task's
waitee before submitting the request, so `cancel!` can find the wait and
issue `uv_cancel` on the outstanding `uv_write_t` (through a new
`cancel_wait!` method for LibuvStream). A cancelled write completes
through the regular write callback with UV_ECANCELED, which reports the
partial write count (`uv_write_nwritten`) back to the waiting task; the
pending cancellation request is then raised at the following
cancellation point.
The write callback now also translates write errors into exceptions
directly (instead of returning a status for the waiter to check), since
the waiter needs to distinguish partial cancelled writes from failures.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012nCkyKUguncLLJrH9K5o7m