| 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 | |
| 696 | bool AwaitTask::await_ready() const { return not isActive(); } |
| 697 | |
| 698 | bool AwaitTask::await_suspend(Handle parent) |
| 699 | { |
| 700 | if (not isActive()) |
| 701 | { |
| 702 | return false; |
| 703 | } |
| 704 | |