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
672Result AwaitTask::cancel(AwaitEventLoop& await)
673{
674 if (not handle)
675 {
676 return Result::Error("AwaitTask is invalid");
677 }
678 Promise& promise = handle.promise();
679 if (promise.completed)
680 {
681 return Result(true);
682 }
683 if (promise.eventLoop != nullptr and promise.eventLoop != &await)
684 {
685 return AwaitWrongEventLoopResult();
686 }
687 if (not promise.started)
688 {
689 return Result::Error("AwaitTask is not started");
690 }
691 if (promise.cancellationRequested)
692 {
693 return Result(true);
694 }
695 if (promise.cancellation.cancel == nullptr)
696 {
697 return Result::Error("AwaitTask cannot be cancelled right now");
698 }
699 promise.cancellationRequested = true;
700 return promise.cancellation.cancel(promise.cancellation.object, await);
701}
702
703bool AwaitTask::await_ready() const { return not isActive(); }
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