subtaskCancelWhenReady method
Executes subtask.cancel and waits when the operation is non-async.
Implementation
Future<int> subtaskCancelWhenReady(
int subtask, {
required bool isAsync,
}) async {
final value = table.get<WASIComponentSubtask>(_subtaskType, subtask);
final event = _requestSubtaskCancellation(value, subtask, isAsync: isAsync);
if (event != null) {
return event;
}
if (isAsync) {
return wasiComponentSubtaskBlocked;
}
return value.waitable.withSyncWaiter(
() => _waitForResolvedSubtaskEvent(value, subtask),
);
}