HH\Asio\cancel

Cancel Awaitable, if it's still pending

Description

function cancel<T>(
  Awaitable<T> $awaitable,
  Exception $exception,
): bool

If Awaitable has not been completed yet, fails Awaitable with $exception and returns true. Otherwise, returns false.

Throws InvalidArgumentException, if Awaitable does not support cancellation.

Parameters

  • Awaitable<T> $awaitable
  • Exception $exception