<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>The EventBase class</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="event.timer.html">Event::timer</a></div> <div class="next" style="text-align: right; float: right;"><a href="eventbase.construct.html">EventBase::__construct</a></div> <div class="up"><a href="book.event.html">Event</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="class.eventbase" class="reference"> <h1 class="title">The EventBase class</h1> <div class="partintro"><p class="verinfo">(PECL event >= 1.2.6-beta)</p> <div class="section" id="eventbase.intro"> <h2 class="title">Introduction</h2> <p class="para"> <strong class="classname">EventBase</strong> class represents libevent's event base structure. It holds a set of events and can poll to determine which events are active. </p> <p class="para"> Each event base has a <em class="emphasis">method</em> , or a <em class="emphasis">backend</em> that it uses to determine which events are ready. The recognized methods are: <em>select</em> , <em>poll</em> , <em>epoll</em> , <em>kqueue</em> , <em>devpoll</em> , <em>evport</em> and <em>win32</em> . </p> <p class="para"> To configure event base to use, or avoid specific backend <a href="class.eventconfig.html" class="classname">EventConfig</a> class can be used. </p> <div class="warning"><strong class="warning">Warning</strong> <p class="para"> Do <em class="emphasis">NOT</em> destroy the <strong class="classname">EventBase</strong> object as long as resources of the associated <em>Event</em> objects are not released. Otherwise, it will lead to unpredictable results! </p> </div> </div> <div class="section" id="eventbase.synopsis"> <h2 class="title">Class synopsis</h2> <div class="classsynopsis"> <div class="ooclass"> </div> <div class="classsynopsisinfo"> <span class="ooclass"> <span class="modifier">final</span> <strong class="classname">EventBase</strong> </span> {</div> <div class="classsynopsisinfo classsynopsisinfo_comment">/* Constants */</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.eventbase.html#eventbase.constants.loop-once"><var class="varname">LOOP_ONCE</var></a></var> <span class="initializer"> = 1</span> ;</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.eventbase.html#eventbase.constants.loop-nonblock"><var class="varname">LOOP_NONBLOCK</var></a></var> <span class="initializer"> = 2</span> ;</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.eventbase.html#eventbase.constants.nolock"><var class="varname">NOLOCK</var></a></var> <span class="initializer"> = 1</span> ;</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.eventbase.html#eventbase.constants.startup-iocp"><var class="varname">STARTUP_IOCP</var></a></var> <span class="initializer"> = 4</span> ;</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.eventbase.html#eventbase.constants.no-cache-time"><var class="varname">NO_CACHE_TIME</var></a></var> <span class="initializer"> = 8</span> ;</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.eventbase.html#eventbase.constants.epoll-use-changelist"><var class="varname">EPOLL_USE_CHANGELIST</var></a></var> <span class="initializer"> = 16</span> ;</div> <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><a href="eventbase.construct.html" class="methodname">__construct</a></span> ([ <span class="methodparam"> <span class="type"><a href="class.eventconfig.html" class="type EventConfig">EventConfig</a></span> <code class="parameter">$cfg</code> </span> ] )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="eventbase.dispatch.html" class="methodname">dispatch</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="eventbase.exit.html" class="methodname">exit</a></span> ([ <span class="methodparam"> <span class="type">double</span> <code class="parameter">$timeout</code> </span> ] )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">int</span> <span class="methodname"><a href="eventbase.getfeatures.html" class="methodname">getFeatures</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><a href="eventbase.getmethod.html" class="methodname">getMethod</a></span> ([ <span class="methodparam"> <span class="type"><a href="class.eventconfig.html" class="type EventConfig">EventConfig</a></span> <code class="parameter">$cfg</code> </span> ] )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">double</span> <span class="methodname"><a href="eventbase.gettimeofdaycached.html" class="methodname">getTimeOfDayCached</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="eventbase.gotexit.html" class="methodname">gotExit</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="eventbase.gotstop.html" class="methodname">gotStop</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><a href="eventbase.loop.html" class="methodname">loop</a></span> ([ <span class="methodparam"> <span class="type">int</span> <code class="parameter">$flags</code> </span> ] )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><a href="eventbase.priorityinit.html" class="methodname">priorityInit</a></span> ( <span class="methodparam"> <span class="type">string</span> <code class="parameter">$n_priorities</code> </span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">void</span> <span class="methodname"><a href="eventbase.reinit.html" class="methodname">reInit</a></span> ( <span class="methodparam"> <span class="type">string</span> <code class="parameter">$base</code> </span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><a href="eventbase.stop.html" class="methodname">stop</a></span> ( <span class="methodparam">void</span> )</div> }</div> </div> <div class="section" id="eventbase.constants"> <h2 class="title">Predefined Constants</h2> <dl> <dt id="eventbase.constants.loop-once"> <span class="term"> <strong><code>EventBase::LOOP_ONCE</code></strong> </span> <dd> <p class="para"> Flag used with <span class="methodname"><a href="eventbase.loop.html" class="methodname">EventBase::loop()</a></span> method which means: "block until libevent has an active event, then exit once all active events have had their callbacks run". </p> </dd> </dt> <dt id="eventbase.constants.loop-nonblock"> <span class="term"> <strong><code>EventBase::LOOP_NONBLOCK</code></strong> </span> <dd> <p class="para"> Flag used with <span class="methodname"><a href="eventbase.loop.html" class="methodname">EventBase::loop()</a></span> method which means: "do not block: see which events are ready now, run the callbacks of the highest-priority ones, then exit". </p> </dd> </dt> <dt id="eventbase.constants.nolock"> <span class="term"> <strong><code>EventBase::NOLOCK</code></strong> </span> <dd> <p class="para"> Configuration flag. Do not allocate a lock for the event base, even if we have locking set up". </p> </dd> </dt> <dt id="eventbase.constants.startup-iocp"> <span class="term"> <strong><code>EventBase::STARTUP_IOCP</code></strong> </span> <dd> <p class="para"> Windows-only configuration flag. Enables the IOCP dispatcher at startup. </p> </dd> </dt> <dt id="eventbase.constants.no-cache-time"> <span class="term"> <strong><code>EventBase::NO_CACHE_TIME</code></strong> </span> <dd> <p class="para"> Configuration flag. Instead of checking the current time every time the event loop is ready to run timeout callbacks, check after each timeout callback. </p> </dd> </dt> <dt id="eventbase.constants.epoll-use-changelist"> <span class="term"> <strong><code>EventBase::EPOLL_USE_CHANGELIST</code></strong> </span> <dd> <p class="para"> If we are using the <em>epoll</em> 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. </p> <p class="para"> 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. </p> <p class="para"> This flag can also be activated by settnig the <em>EVENT_EPOLL_USE_CHANGELIST</em> environment variable. </p> <p class="para"> This flag has no effect if one winds up using a backend other than <em>epoll</em> . </p> </dd> </dt> </dl> </div> </div> <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="eventbase.construct.html">EventBase::__construct</a> — Constructs EventBase object</li><li><a href="eventbase.dispatch.html">EventBase::dispatch</a> — Dispatch pending events</li><li><a href="eventbase.exit.html">EventBase::exit</a> — Stop dispatching events</li><li><a href="eventbase.getfeatures.html">EventBase::getFeatures</a> — Returns bitmask of features supported</li><li><a href="eventbase.getmethod.html">EventBase::getMethod</a> — Returns event method in use</li><li><a href="eventbase.gettimeofdaycached.html">EventBase::getTimeOfDayCached</a> — Returns the current event base time</li><li><a href="eventbase.gotexit.html">EventBase::gotExit</a> — Checks if the event loop was told to exit</li><li><a href="eventbase.gotstop.html">EventBase::gotStop</a> — Checks if the event loop was told to exit</li><li><a href="eventbase.loop.html">EventBase::loop</a> — Dispatch pending events</li><li><a href="eventbase.priorityinit.html">EventBase::priorityInit</a> — Sets number of priorities per event base</li><li><a href="eventbase.reinit.html">EventBase::reInit</a> — Re-initialize event base(after a fork).</li><li><a href="eventbase.stop.html">EventBase::stop</a> — Tells event_base to stop dispatching events</li></ul> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="event.timer.html">Event::timer</a></div> <div class="next" style="text-align: right; float: right;"><a href="eventbase.construct.html">EventBase::__construct</a></div> <div class="up"><a href="book.event.html">Event</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>