fibers: drop redundant async_void — the variadic async covers nullary workers
async_void :: ufcs (io, worker: Closure() -> $R) -> Future($R) was redundant: the variadic async :: ufcs (io, worker: Closure(..$args) -> $R, ..$args) binds $args to the empty pack, so context.io.async(() -> $R => ...) already calls worker() and returns Future($R). The name was also misleading — it returns Future($R), not void (a true void form is Future(void), separate, blocked by issue 0150). Removed the definition (std/io.sx) + the std.sx re-export; nothing else referenced it. Locked the nullary path in examples/1805 (prints nullary: 42) so the coverage async_void provided is not lost. Suite green 736/0.
This commit is contained in:
@@ -18,6 +18,11 @@ main :: () {
|
|||||||
d := context.io.async((x: i64) -> i64 => x * 2, 21);
|
d := context.io.async((x: i64) -> i64 => x * 2, 21);
|
||||||
print("double: {}\n", d.await() or { -1 });
|
print("double: {}\n", d.await() or { -1 });
|
||||||
|
|
||||||
|
// Nullary worker — the variadic `async` binds an empty pack, so no separate
|
||||||
|
// `async_void` entry is needed.
|
||||||
|
n := context.io.async(() -> i64 => 42);
|
||||||
|
print("nullary: {}\n", n.await() or { -1 });
|
||||||
|
|
||||||
// The Io capability also carries a monotonic clock.
|
// The Io capability also carries a monotonic clock.
|
||||||
if context.io.now_ms() >= 0 { print("clock ok\n"); }
|
if context.io.now_ms() >= 0 { print("clock ok\n"); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
sum: 42
|
sum: 42
|
||||||
double: 42
|
double: 42
|
||||||
|
nullary: 42
|
||||||
clock ok
|
clock ok
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ Future :: io_mod.Future;
|
|||||||
FutureState :: io_mod.FutureState;
|
FutureState :: io_mod.FutureState;
|
||||||
IoErr :: io_mod.IoErr;
|
IoErr :: io_mod.IoErr;
|
||||||
async :: io_mod.async;
|
async :: io_mod.async;
|
||||||
async_void :: io_mod.async_void;
|
|
||||||
await :: io_mod.await;
|
await :: io_mod.await;
|
||||||
cancel :: io_mod.cancel;
|
cancel :: io_mod.cancel;
|
||||||
// `timeout` / `Future(void)` are DEFERRED (B1.4) pending issue 0150
|
// `timeout` / `Future(void)` are DEFERRED (B1.4) pending issue 0150
|
||||||
|
|||||||
@@ -107,14 +107,9 @@ async :: ufcs (io: Io, worker: Closure(..$args) -> $R, ..$args) -> Future($R) {
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nullary form — no args. A worker that takes no arguments.
|
// (A nullary worker needs no separate entry: the variadic `async` above binds
|
||||||
async_void :: ufcs (io: Io, worker: Closure() -> $R) -> Future($R) {
|
// `..$args` to the empty pack, so `context.io.async(() -> $R => …)` calls
|
||||||
f : Future($R) = ---;
|
// `worker()` and returns `Future($R)`. Locked by examples/1805.)
|
||||||
f.value = worker();
|
|
||||||
f.state = .ready;
|
|
||||||
f.canceled = Atomic(bool).init(false);
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// `await(f)` — value-carrying failable. `.ready` → the result; `.failed`
|
// `await(f)` — value-carrying failable. `.ready` → the result; `.failed`
|
||||||
// / `.canceled` → raise the stored / cancellation error.
|
// / `.canceled` → raise the stored / cancellation error.
|
||||||
|
|||||||
Reference in New Issue
Block a user