Skip to content

Commit 7490960

Browse files
chore: rename revoke_buffer to reclaim_buffer (#538)
This commit renames `revoke_buffer` which is used during stream copying to `reclaim_buffer` which hopefully better conveys (if only slightly) the handoff/change in ownership of the buffer in use. Signed-off-by: Victor Adossi <[email protected]>
1 parent e362068 commit 7490960

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

design/mvp/CanonicalABI.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,8 +1272,8 @@ client to asynchronously read multiple values from a (wasm or host) producer.
12721272
that there is no Component Model type for passing the writable end of a
12731273
stream.)
12741274
```python
1275-
RevokeBuffer = Callable[[], None]
1276-
OnCopy = Callable[[RevokeBuffer], None]
1275+
ReclaimBuffer = Callable[[], None]
1276+
OnCopy = Callable[[ReclaimBuffer], None]
12771277
OnCopyDone = Callable[[CopyResult], None]
12781278

12791279
class ReadableStream:
@@ -1291,7 +1291,7 @@ The key operation is `read` which works as follows:
12911291
* `OnCopy` is called to indicate a write has been made into the buffer.
12921292
However, there may be further writes made in the future, so the caller has
12931293
*not* regained ownership of the buffer.
1294-
* The `RevokeBuffer` callback passed to `OnCopy` allows the caller of `read` to
1294+
* The `ReclaimBuffer` callback passed to `OnCopy` allows the caller of `read` to
12951295
immediately regain ownership of the buffer once the first copy has completed.
12961296
* `cancel` is non-blocking, but does **not** guarantee that ownership of
12971297
the buffer has been returned; `cancel` only lets the caller *request* that
@@ -1305,7 +1305,7 @@ concurrent behaviors of `stream.{read,write}` and not exposed directly to core
13051305
wasm code. Specifically, the point of the `OnCopy*` callbacks is to specify that
13061306
*multiple* writes are allowed into the same `WritableBuffer` up until the point
13071307
where either the buffer is full or the calling core wasm code receives the
1308-
`STREAM_READ` progress event (in which case `RevokeBuffer` is called). This
1308+
`STREAM_READ` progress event (in which case `ReclaimBuffer` is called). This
13091309
reduces the number of task-switches required by the spec, particularly when
13101310
streaming between two components.
13111311

@@ -3880,7 +3880,7 @@ Next, the `copy` method of `{Readable,Writable}{Stream,Future}End` is called to
38803880
perform the actual read/write. The `on_copy*` callbacks passed to `copy` bind
38813881
and store a `stream_event` closure on the readable/writable end (via the
38823882
inherited `Waitable.set_event`) which will be called right before the event is
3883-
delivered to core wasm. `stream_event` first calls `revoke_buffer` to regain
3883+
delivered to core wasm. `stream_event` first calls `reclaim_buffer` to regain
38843884
ownership of `buffer` and prevent any further partial reads/writes. Thus, up
38853885
until event delivery, the other end of the stream is free to repeatedly
38863886
read/write from/to `buffer`, ideally filling it up and minimizing context
@@ -3890,8 +3890,8 @@ all future use of this stream end. Lastly, `stream_event` packs the
38903890
`CopyResult` and number of elements copied up until this point into a single
38913891
`i32` payload for core wasm.
38923892
```python
3893-
def stream_event(result, revoke_buffer):
3894-
revoke_buffer()
3893+
def stream_event(result, reclaim_buffer):
3894+
reclaim_buffer()
38953895
assert(e.copying)
38963896
e.copying = False
38973897
if result == CopyResult.DROPPED:
@@ -3902,11 +3902,11 @@ all future use of this stream end. Lastly, `stream_event` packs the
39023902
return (event_code, i, packed_result)
39033903
return (event_code, i, pack_stream_result(result, buffer))
39043904

3905-
def on_copy(revoke_buffer):
3906-
e.set_event(partial(stream_event, CopyResult.COMPLETED, revoke_buffer))
3905+
def on_copy(reclaim_buffer):
3906+
e.set_event(partial(stream_event, CopyResult.COMPLETED, reclaim_buffer))
39073907

39083908
def on_copy_done(result):
3909-
e.set_event(partial(stream_event, result, revoke_buffer = lambda:()))
3909+
e.set_event(partial(stream_event, result, reclaim_buffer = lambda:()))
39103910

39113911
e.copying = True
39123912
e.copy(task.inst, buffer, on_copy, on_copy_done)

design/mvp/canonical-abi/definitions.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,8 @@ class CopyResult(IntEnum):
757757
DROPPED = 1
758758
CANCELLED = 2
759759

760-
RevokeBuffer = Callable[[], None]
761-
OnCopy = Callable[[RevokeBuffer], None]
760+
ReclaimBuffer = Callable[[], None]
761+
OnCopy = Callable[[ReclaimBuffer], None]
762762
OnCopyDone = Callable[[CopyResult], None]
763763

764764
class ReadableStream:
@@ -2259,8 +2259,8 @@ async def stream_copy(EndT, BufferT, event_code, stream_t, opts, task, i, ptr, n
22592259
cx = LiftLowerContext(opts, task.inst, borrow_scope = None)
22602260
buffer = BufferT(stream_t.t, cx, ptr, n)
22612261

2262-
def stream_event(result, revoke_buffer):
2263-
revoke_buffer()
2262+
def stream_event(result, reclaim_buffer):
2263+
reclaim_buffer()
22642264
assert(e.copying)
22652265
e.copying = False
22662266
if result == CopyResult.DROPPED:
@@ -2271,11 +2271,11 @@ def stream_event(result, revoke_buffer):
22712271
return (event_code, i, packed_result)
22722272
return (event_code, i, pack_stream_result(result, buffer))
22732273

2274-
def on_copy(revoke_buffer):
2275-
e.set_event(partial(stream_event, CopyResult.COMPLETED, revoke_buffer))
2274+
def on_copy(reclaim_buffer):
2275+
e.set_event(partial(stream_event, CopyResult.COMPLETED, reclaim_buffer))
22762276

22772277
def on_copy_done(result):
2278-
e.set_event(partial(stream_event, result, revoke_buffer = lambda:()))
2278+
e.set_event(partial(stream_event, result, reclaim_buffer = lambda:()))
22792279

22802280
e.copying = True
22812281
e.copy(task.inst, buffer, on_copy, on_copy_done)

design/mvp/canonical-abi/run_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,8 @@ def __init__(self, shared, chunk, remain = 2**64):
10881088
async def read_all():
10891089
while True:
10901090
await self.write_event.wait()
1091-
def on_copy(revoke_buffer):
1092-
revoke_buffer()
1091+
def on_copy(reclaim_buffer):
1092+
reclaim_buffer()
10931093
if not f.done():
10941094
f.set_result(None)
10951095
def on_copy_done(result):

0 commit comments

Comments
 (0)