pub fn concurrent(g: *Group, io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function))) ConcurrentError!void ConcurrencyUnavailableMay occur due to a temporary condition such as resource exhaustion, or to the Io implementation not supporting concurrency.
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387 pub fn concurrent(g: *Group, io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function))) ConcurrentError!void {
const Args = @TypeOf(args);
const TypeErased = struct {
fn start(context: *const anyopaque) void {
const args_casted: *const Args = @ptrCast(@alignCast(context));
_ = @as(Cancelable!void, @call(.auto, function, args_casted.*)) catch {};
}
};
return io.vtable.groupConcurrent(io.userdata, g, @ptrCast(&args), .of(Args), TypeErased.start);
}
Equivalent to
Io.concurrent, except the task is spawned in thisGroupinstead of becoming associated with aFuture.The return type of
functionmust be coercible toCancelable!void.functionreturningerror.Canceleddoes nothing because it is an cancelation propagation boundary.Once this function is called, there are resources associated with the group. To release those resources,
Group.awaitorGroup.cancelmust eventually be called.