EVENTBASE(3) 1 EVENTBASE(3)The EventBase classINTRODUCTION
EventBase class represents libevent's event base structure. It holds a set of events and can poll to determine which events are active.
Each event base has a method , or a backend that it uses to determine which events are ready. The recognized methods are: select , poll ,
epoll , kqueue , devpoll , evport and win32 .
To configure event base to use, or avoid specific backend EventConfig class can be used.
Warning
Do NOT destroy the EventBase object as long as resources of the associated Event objects are not released. Otherwise, it will lead
to unpredictable results!
CLASS SYNOPSIS
EventBase
final
EventBase
Constants
o const integer$EventBase::LOOP_ONCE1
o const integer$EventBase::LOOP_NONBLOCK2
o const integer$EventBase::NOLOCK1
o const integer$EventBase::STARTUP_IOCP4
o const integer$EventBase::NO_CACHE_TIME8
o const integer$EventBase::EPOLL_USE_CHANGELIST16
Methods
o public EventBase::__construct ([EventConfig $cfg])
o public void EventBase::dispatch (void )
o public bool EventBase::exit ([double $timeout])
o public void EventBase::free (void )
o public int EventBase::getFeatures (void )
o public string EventBase::getMethod ([EventConfig $cfg])
o public double EventBase::getTimeOfDayCached (void )
o public bool EventBase::gotExit (void )
o public bool EventBase::gotStop (void )
o public bool EventBase::loop ([int $flags])
o public bool EventBase::priorityInit (int $n_priorities)
o public bool EventBase::reInit (void )
o public bool EventBase::stop (void )
PREDEFINED CONSTANTS
o EventBase::LOOP_ONCE - Flag used with EventBase::loop method which means: "block until libevent has an active event, then exit
once all active events have had their callbacks run".
o EventBase::LOOP_NONBLOCK - Flag used with EventBase::loop method which means: "do not block: see which events are ready now, run
the callbacks of the highest-priority ones, then exit".
o EventBase::NOLOCK - Configuration flag. Do not allocate a lock for the event base, even if we have locking set up".
o EventBase::STARTUP_IOCP - Windows-only configuration flag. Enables the IOCP dispatcher at startup.
o EventBase::NO_CACHE_TIME - Configuration flag. Instead of checking the current time every time the event loop is ready to run
timeout callbacks, check after each timeout callback.
o EventBase::EPOLL_USE_CHANGELIST - If we are using the epoll backend, this flag says that it is safe to use Libevent's internal
change-list code to batch up adds and deletes in order to try to do as few syscalls as possible. Setting this flag can make code
run faster, but it may trigger a Linux bug: it is not safe to use this flag if one has any fds cloned by dup(), or its variants.
Doing so will produce strange and hard-to-diagnose bugs. This flag can also be activated by settnig the EVENT_EPOLL_USE_CHANGE-
LIST environment variable. This flag has no effect if one winds up using a backend other than epoll .
PHP Documentation Group EVENTBASE(3)
Check Out this Related Man Page
EVENTBUFFEREVENT(3) 1 EVENTBUFFEREVENT(3)The EventBufferEvent classINTRODUCTION
Represents Libevent's buffer event.
Usually an application wants to perform some amount of data buffering in addition to just responding to events. When we want to write
data, for example, the usual pattern looks like:
o Decide that we want to write some data to a connection; put that data in a buffer.
o Wait for the connection to become writable
o Write as much of the data as we can
o Remember how much we wrote, and if we still have more data to write, wait for the connection to become writable again.
This buffered I/O pattern is common enough that Libevent provides a generic mechanism for it. A "buffer event" consists of an underlying
transport (like a socket), a read buffer, and a write buffer. Instead of regular events, which give callbacks when the underlying transport
is ready to be read or written, a buffer event invokes its user-supplied callbacks when it has read or written enough data.
CLASS SYNOPSIS
EventBufferEvent
final
EventBufferEvent
Constants
o const integer$EventBufferEvent::READING1
o const integer$EventBufferEvent::WRITING2
o const integer$EventBufferEvent::EOF16
o const integer$EventBufferEvent::ERROR32
o const integer$EventBufferEvent::TIMEOUT64
o const integer$EventBufferEvent::CONNECTED128
o const integer$EventBufferEvent::OPT_CLOSE_ON_FREE1
o const integer$EventBufferEvent::OPT_THREADSAFE2
o const integer$EventBufferEvent::OPT_DEFER_CALLBACKS4
o const integer$EventBufferEvent::OPT_UNLOCK_CALLBACKS8
o const integer$EventBufferEvent::SSL_OPEN0
o const integer$EventBufferEvent::SSL_CONNECTING1
o const integer$EventBufferEvent::SSL_ACCEPTING2
Properties
o public integer$fd
o public integer$priority
o publicreadonly EventBuffer$input
o publicreadonly EventBuffer$output
Methods
o public void EventBufferEvent::close (void )
o public bool EventBufferEvent::connect (string $addr)
o public bool EventBufferEvent::connectHost (EventDnsBase $dns_base, string $hostname, int $port, [int $family = EventUtil::AF_UNSPEC])
o public EventBufferEvent::__construct NULL NULL NULL NULL (EventBase $base, [mixed $socket], [int $options], [callable $readcb],
[callable $writecb], [callable $eventcb])
o publicstatic array EventBufferEvent::createPair (EventBase $base, [int $options])
o public bool EventBufferEvent::disable (int $events)
o public bool EventBufferEvent::enable (int $events)
o public void EventBufferEvent::free (void )
o public string EventBufferEvent::getDnsErrorString (void )
o public int EventBufferEvent::getEnabled (void )
o public EventBuffer EventBufferEvent::getInput (void )
o public EventBuffer EventBufferEvent::getOutput (void )
o public string EventBufferEvent::read (int $size)
o public bool EventBufferEvent::readBuffer (EventBuffer $buf)
o public void EventBufferEvent::setCallbacks (callable $readcb, callable $writecb, callable $eventcb, [string $arg])
o public bool EventBufferEvent::setPriority (int $priority)
o public bool EventBufferEvent::setTimeouts (float $timeout_read, float $timeout_write)
o public void EventBufferEvent::setWatermark (int $events, int $lowmark, int $highmark)
o public string EventBufferEvent::sslError (void )
o publicstatic EventBufferEvent EventBufferEvent::sslFilter (EventBase $base, EventBufferEvent $underlying, EventSslContext $ctx, int
$state, [int $options])
o public string EventBufferEvent::sslGetCipherInfo (void )
o public string EventBufferEvent::sslGetCipherName (void )
o public string EventBufferEvent::sslGetCipherVersion (void )
o public string EventBufferEvent::sslGetProtocol (void )
o public void EventBufferEvent::sslRenegotiate (void )
o publicstatic EventBufferEvent EventBufferEvent::sslSocket (EventBase $base, mixed $socket, EventSslContext $ctx, int $state, [int
$options])
o public bool EventBufferEvent::write (string $data)
o public bool EventBufferEvent::writeBuffer (EventBuffer $buf)
PROPERTIES
o $fd
- Numeric file descriptor associated with the buffer event. Normally represents a bound socket. Equals to NULL, if there is no
file descriptor(socket) associated with the buffer event.
o $priority
- The priority of the events used to implement the buffer event.
o $input
- Underlying input buffer object( EventBuffer )
o $output
- Underlying output buffer object( EventBuffer )
PREDEFINED CONSTANTS
o EventBufferEvent::READING - An event occured during a read operation on the bufferevent. See the other flags for which event it
was.
o EventBufferEvent::WRITING - An event occured during a write operation on the bufferevent. See the other flags for which event it
was.
o EventBufferEvent::EOF - Got an end-of-file indication on the buffer event.
o EventBufferEvent::ERROR - An error occurred during a bufferevent operation. For more information on what the error was, call Even-
tUtil::getLastSocketErrno and/or EventUtil::getLastSocketError .
o EventBufferEvent::TIMEOUT -
o EventBufferEvent::CONNECTED - Finished a requested connection on the bufferevent.
o EventBufferEvent::OPT_CLOSE_ON_FREE - When the buffer event is freed, close the underlying transport. This will close an underly-
ing socket, free an underlying buffer event, etc.
o EventBufferEvent::OPT_THREADSAFE - Automatically allocate locks for the bufferevent, so that it's safe to use from multiple
threads.
o EventBufferEvent::OPT_DEFER_CALLBACKS - When this flag is set, the bufferevent defers all of its callbacks. See Fast portable non-
blocking network programming with Libevent, Deferred callbacks .
o EventBufferEvent::OPT_UNLOCK_CALLBACKS - By default, when the bufferevent is set up to be threadsafe, the buffer event's locks are
held whenever the any user-provided callback is invoked. Setting this option makes Libevent release the buffer event's lock when
it's invoking the callbacks.
o EventBufferEvent::SSL_OPEN - The SSL handshake is done
o EventBufferEvent::SSL_CONNECTING - SSL is currently performing negotiation as a client
o EventBufferEvent::SSL_ACCEPTING - SSL is currently performing negotiation as a server
PHP Documentation Group EVENTBUFFEREVENT(3)