phasync
Blocking calls and the extension / CurlAwaiter

Class

CurlAwaiter

Runs cURL handles cooperatively, so other coroutines run while a request is in flight.

Introduction#

curl_exec() blocks the whole process; CurlAwaiter::await() suspends only the calling coroutine. Use it where the phasync extension is not loaded, or to be independent of it. All handles awaited in a process share one curl_multi handle, driven by whichever coroutine is waiting.

Class synopsis#

final class CurlAwaiter {
    /* Methods */
    public static CurlAwaiter::await(CurlHandle $ch): mixed
}

Methods#

MethodDescription
awaitRuns $ch to completion and returns its body, without blocking other coroutines.

See also#

  • phasync::goStart the coroutines that make requests side by side