interface User (View source)

Interface to an user event loop implementation for http\Client::configure()'s $use_eventloop option.

NOTE: This interface was added in v2.6.0, resp. v3.1.0.

Constants

POLL_NONE

No action.

POLL_IN

Poll for read readiness.

POLL_OUT

Poll for write readiness.

POLL_INOUT

Poll for read/write readiness.

POLL_REMOVE

Stop polling for activity on this descriptor.

Methods

init(callable $run)

Initialize the event loop.

once()

Run the loop as long as it does not block.

send()

Run the loop.

socket(resource $socket, int $poll)

Register (or deregister) a socket watcher.

timer(int $timeout_ms)

Register a timeout watcher.

wait(int $timeout_ms = null)

Wait/poll/select (block the loop) until events fire.

Details

init(callable $run)

Initialize the event loop.

Parameters

callable $run

as function(http\Client $c, resource $s = null, int $action = http\Client\Curl\User::POLL_NONE) : int Internal callback returning the number of unfinished requests pending.

NOTE: The callback should be run when a timeout occurs or a watched socket needs action.

once()

Run the loop as long as it does not block.

NOTE: This method is called by http\Client::once(), so it does not need to have an actual implementation if http\Client::once() is never called.

send()

Run the loop.

NOTE: This method is called by http\Client::send(), so it does not need to have an actual implementation if http\Client::send() is never called.

socket(resource $socket, int $poll)

Register (or deregister) a socket watcher.

Parameters

resource $socket

The socket descriptor to watch.

int $poll

http\Client\Curl\User::POLL_* constant.

timer(int $timeout_ms)

Register a timeout watcher.

Parameters

int $timeout_ms

Desired maximum timeout in milliseconds.

wait(int $timeout_ms = null)

Wait/poll/select (block the loop) until events fire.

NOTE: This method is called by http\Client::wait(), so it does not need to have an actual implementation if http\Client::wait() is never called.

Parameters

int $timeout_ms

Block for at most this milliseconds.