HH\Asio\cancel

Cancel Awaitable, if it's still pending

namespace HH\Asio;

function cancel<T>(
  Awaitable<T, mixed> $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

Returns

  • bool