-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I don't know if "cancel" is a good term; I am not even sure if cancellation is a correct thing to do in a promise framework, where promise is just a state machine (unlike Rust futures, where you need to await a future to actually execute it).
Design
function read_line_await(LineBufReader $reader) {
$resolve = yield Await::RESOLVE;
$isCancelled = yield Await::IS_CANCEL;
$reader->shiftLineCallback(function($line) use($isCancelled, $resolve) {
if($isCancelled()) {
$reader->unshiftLine($line);
} else {
$resolve($line);
}
});
}
When we Await::race
multiple generators, the losing generators are set to be cancelled
Concerns
Coroutines are not necessarily cancellatoin-aware. They need to explicitly indicate what they do when they are cancelled (in particular, stateful promises need to reset the states they changed), which is a usability issue.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request