Skip to content

Commit 6593f77

Browse files
committed
src: document DoWrite() usage expectations
Clarify how it must behave for both synchronous and asynchronous completion. PR-URL: #26339 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent d775d74 commit 6593f77

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/stream_base.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,14 @@ class StreamResource {
207207
// `*bufs` and `*count` accordingly. This is a no-op by default.
208208
// Return 0 for success and a libuv error code for failures.
209209
virtual int DoTryWrite(uv_buf_t** bufs, size_t* count);
210-
// Perform a write of data, and either call req_wrap->Done() when finished
211-
// and return 0, or return a libuv error code for synchronous failures.
210+
// Initiate a write of data. If the write completes synchronously, return 0 on
211+
// success (with bufs modified to indicate how much data was consumed) or a
212+
// libuv error code on failure. If the write will complete asynchronously,
213+
// return 0. When the write completes asynchronously, call req_wrap->Done()
214+
// with 0 on success (with bufs modified to indicate how much data was
215+
// consumed) or a libuv error code on failure. Do not call req_wrap->Done() if
216+
// the write completes synchronously, that is, it should never be called
217+
// before DoWrite() has returned.
212218
virtual int DoWrite(WriteWrap* w,
213219
uv_buf_t* bufs,
214220
size_t count,

0 commit comments

Comments
 (0)