Skip to content

Commit

Permalink
Make splice atomic.
Browse files Browse the repository at this point in the history
  • Loading branch information
badeend committed Feb 14, 2024
1 parent 324be89 commit c0c2fcc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ let _ = this.check-write(); // eliding error handling
<code>check-write</code> permitted length and the <code>len</code> provided to <code>splice</code></li>
<li>calling <code>write</code> on the <a href="#output_stream"><code>output-stream</code></a> with that read data.</li>
</ol>
<p>This function behaves as-if these steps are performed atomically.
I.e. if the read (in step 2) succeeds, but the write (in step 3) fails,
future reads will first read from the buffer alread retrieved in step 2.</p>
<p>Any error reported by the call to <code>check-write</code>, <code>read</code>, or
<code>write</code> ends the splice and reports that error.</p>
<p>This function returns the number of bytes transferred; it may be less
Expand Down
4 changes: 4 additions & 0 deletions wit/streams.wit
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ interface streams {
/// `check-write` permitted length and the `len` provided to `splice`
/// 3. calling `write` on the `output-stream` with that read data.
///
/// This function behaves as-if these steps are performed atomically.
/// I.e. if the read (in step 2) succeeds, but the write (in step 3) fails,
/// future reads will first read from the buffer alread retrieved in step 2.
///
/// Any error reported by the call to `check-write`, `read`, or
/// `write` ends the splice and reports that error.
///
Expand Down

0 comments on commit c0c2fcc

Please sign in to comment.