From c0c2fcc956a6b2bb813d6d3fe6568591bb54849b Mon Sep 17 00:00:00 2001 From: Dave Bakker Date: Wed, 14 Feb 2024 17:44:59 +0100 Subject: [PATCH] Make splice atomic. --- imports.md | 3 +++ wit/streams.wit | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/imports.md b/imports.md index 1ae5b12..faad09c 100644 --- a/imports.md +++ b/imports.md @@ -389,6 +389,9 @@ let _ = this.check-write(); // eliding error handling check-write permitted length and the len provided to splice
  • 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.

    This function returns the number of bytes transferred; it may be less diff --git a/wit/streams.wit b/wit/streams.wit index 6d2f871..a70c79f 100644 --- a/wit/streams.wit +++ b/wit/streams.wit @@ -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. ///