MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / cancel

Method cancel

Libraries/Await/Await.cpp:672–701  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

670 }
671 Promise& promise = handle.promise();
672 if (promise.completed)
673 {
674 return Result(true);
675 }
676 if (promise.eventLoop != nullptr and promise.eventLoop != &await)
677 {
678 return AwaitWrongEventLoopResult();
679 }
680 if (not promise.started)
681 {
682 return Result::Error(AwaitResultCategory, AwaitError::TaskNotStarted);
683 }
684 if (promise.cancellationRequested)
685 {
686 return Result(true);
687 }
688 if (promise.cancellation.cancel == nullptr)
689 {
690 return Result::Error(AwaitResultCategory, AwaitError::TaskCancellationUnavailable);
691 }
692 promise.cancellationRequested = true;
693 return promise.cancellation.cancel(promise.cancellation.object, await);
694}
695
696bool AwaitTask::await_ready() const { return not isActive(); }
697
698bool AwaitTask::await_suspend(Handle parent)
699{
700 if (not isActive())
701 {
702 return false;
703 }
704

Callers 15

cancelRequestMethod · 0.45
taskLifetimeEdgeCasesMethod · 0.45
taskCrossLoopGuardsMethod · 0.45
cancelSleepMethod · 0.45
cancelEdgeCasesMethod · 0.45
cancelAfterCompletionMethod · 0.45
cancelProcessExitMethod · 0.45
signalMethod · 0.45
cancelSignalMethod · 0.45

Calls 10

cancelCancellableAwaitFunction · 0.85
AwaitCancelledResultFunction · 0.85
isFreeMethod · 0.80
cancelAllMethod · 0.80
activeCountMethod · 0.80
ErrorEnum · 0.50
ResultClass · 0.50
isActiveMethod · 0.45
stopMethod · 0.45

Tested by 15

cancelRequestMethod · 0.36
taskLifetimeEdgeCasesMethod · 0.36
taskCrossLoopGuardsMethod · 0.36
cancelSleepMethod · 0.36
cancelEdgeCasesMethod · 0.36
cancelAfterCompletionMethod · 0.36
cancelProcessExitMethod · 0.36
signalMethod · 0.36
cancelSignalMethod · 0.36