Future::IO::ImplBase(3pm)

NAME
"Future::IO::ImplBase" - base class for "Future::IO" implementations

DESCRIPTION
This package provides a few utility methods that may help writing actual Future::IO implementation classes. It is entirely optional; implementations are not required to use it.

CLASS METHODS

  APPLY
   __PACKAGE__->APPLY;

Attempts to set the value of the $Future::IO::IMPL variable to the name of the calling package.

DEFAULT METHODS
These methods are provided based on lower-level functionallity that the implementing class should provide.

  accept
Implemented by wrapping poll(POLLIN), as "sysread" uses.

  alarm
Implemented by wrapping "sleep".

  connect
Implemented by wrapping poll(POLLOUT), as "syswrite" uses.

  recv

  recvfrom
Implemented by wrapping poll(POLLIN), as "sysread" uses.

  send
Implemented by wrapping poll(POLLOUT), as "syswrite" uses.

  sysread
Requires a lower-level method

   $f = $class->poll( $fh, POLLIN );

which should return a Future that completes when the given filehandle may be ready for reading.

  syswrite
Requires a lower-level method

   $f = $class->poll( $fh, POLLOUT );

which should return a Future that completes when the given filehandle may be ready for writing.

OPTIONAL METHODS
The following methods may be directly provided by an implementation, or they may be emulated by this base class by other means. It is usually better to provide these methods in an implementation if it can do so more efficiently or better in those modules; these emulations are provided as a worst-case fallback and may not be ideal.

These methods will require a helper method provided by the implementation class to construct new "Future" instances of its chosen type.

   $f = $class->_new_future;

  sleep
Since version 0.22.

Emulated by maintaining a queue of "sleep" and "alarm" timers. Two helper methods are provided for the implementation to manage this queue.

   $timeout = $class->_timeout;

   $class->_manage_timers;

The "_timeout" method returns a value in seconds to the delay until when the next timer will expire. This may be "undef" if there are none waiting. The "_manage_timers" method may be called at any time to invoke any of the timers that have now expired.

LEGACY METHODS
The following methods are not considered part of the official "Future::IO" implementation API, and should not be relied upon when writing new code. However, existing code may still exist that uses them so for now they are provided as wrappers.

Later versions of this module may start printing deprecation warnings on these methods, so existing code ought to be updated to use the newer forms now.

  ready_for_read

  ready_for_write
   $f = $class->ready_for_read( $fh );

   $f = $class->ready_for_write( $fh );

Implemented by wrapping "poll" by passing in the "POLLIN" or "POLLOUT" flags respectively.

AUTHOR
Paul Evans <leonerd@leonerd.org.uk>