++ed by:
PINGAN SYP EGOR

3 PAUSE users

Author image Felipe Gasper
and 1 contributors

NAME

Net::Curl::Promiser::Select

DESCRIPTION

This module implements Net::Curl::Promiser via Perl’s select() built-in.

See /examples in the distribution for a fleshed-out demonstration.

This is “the hard way” to do this, by the way. Your life will be simpler if you use (or create) an event-loop-based implementation like Net::Curl::Promiser::AnyEvent or Net::Curl::Promiser::IOAsync. See /examples for comparisons.

METHODS

The following are added in addition to the base class methods:

($rmask, $wmask, $emask) = OBJ->get_vecs();

Returns the bitmasks to use as input to select().

Note that, since these are copies of OBJ’s internal values, you don’t need to copy them again before calling select().

@fds = OBJ->get_fds();

Returns the file descriptors that OBJ tracks—or, in scalar context, the count of such. Useful to check for exception events.

$obj = OBJ->process( $READ_MASK, $WRITE_MASK )

Tell the underlying Net::Curl::Multi object which socket events have happened. $READ_MASK and $WRITE_MASK are as “left” by Perl’s select() built-in.

If, in fact, no events have happened, then this calls socket_action(CURL_SOCKET_TIMEOUT) on the Net::Curl::Multi object (similar to time_out()).

Finally, this reaps whatever pending HTTP responses may be ready and resolves or rejects the corresponding Promise objects.

Returns OBJ.

$is_active = OBJ->time_out();

Tell the underlying Net::Curl::Multi object that a timeout happened, and reap whatever pending HTTP responses may be ready.

Calls socket_action(CURL_SOCKET_TIMEOUT) on the underlying Net::Curl::Multi object. The return is the same as that operation returns.

Since process() can also do the work of this function, a call to this function is just an optimization.

This should only be called from event loop logic.

$num = OBJ->get_timeout()

Like libcurl’s curl_multi_timeout(3), but sometimes returns different values depending on the needs of OBJ.

(NB: This value is in seconds, not milliseconds.)

This should only be called (if it’s called at all) from event loop logic.