<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.evtimer" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
 <title>The EvTimer class</title>
 <titleabbrev>EvTimer</titleabbrev>
 <partintro>
<!-- {{{ EvTimer intro -->
  <section xml:id="evtimer.intro">
   &reftitle.intro;
   <para>
    <classname>EvTimer</classname>
    watchers are simple relative timers that generate an event after a given
    time, and optionally repeating in regular intervals after that.
   </para>
   <para>
    The timers are based on real time, that is, if one registers an event that
    times out after an hour and resets the system clock to
    <emphasis>January last year</emphasis>
    , it will still time out after(roughly) one hour. "Roughly" because
    detecting time jumps is hard, and some inaccuracies are unavoidable.
   </para>
   <para>
    The callback is guaranteed to be invoked only after its timeout has passed
    (not at, so on systems with very low-resolution clocks this might
    introduce a small delay). If multiple timers become ready during the same
    loop iteration then the ones with earlier time-out values are invoked
    before ones of the same priority with later time-out values (but this is
    no longer true when a callback calls
    <methodname>EvLoop::run</methodname>
    recursively).
   </para>
   <para>
    The timer itself will do a best-effort at avoiding drift, that is, if a
    timer is configured to trigger every
    <constant>10</constant>
    seconds, then it will normally trigger at exactly
    <constant>10</constant>
    second intervals. If, however, the script cannot keep up with the timer
    because it takes longer than those
    <constant>10</constant>
    seconds to do) the timer will not fire more than once per event loop
    iteration.
   </para>
  </section>
<!-- }}} -->
  <section xml:id="evtimer.synopsis">
   &reftitle.classsynopsis;

<!-- {{{ Synopsis -->
   <classsynopsis>
    <ooclass>
     <classname>EvTimer</classname>
    </ooclass>
<!-- {{{ Class synopsis -->
    <classsynopsisinfo>
     <ooclass>
      <classname>EvTimer</classname>
     </ooclass>
     <ooclass>
      <modifier>extends</modifier>
      <classname>EvWatcher</classname>
     </ooclass>
    </classsynopsisinfo>
<!-- }}} -->
    <classsynopsisinfo role="comment">&Properties;</classsynopsisinfo>
    <fieldsynopsis>
     <modifier>public</modifier>
     <varname linkend="evtimer.props.repeat">repeat</varname>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>public</modifier>
     <varname linkend="evtimer.props.remaining">remaining</varname>
    </fieldsynopsis>
    <classsynopsisinfo role="comment">&InheritedProperties;</classsynopsisinfo>
    <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('evwatcher.synopsis')/descendant::db:fieldsynopsis)" />
    <classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
    <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.evtimer')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[not(@role='procedural')])"/>
    <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.evtimer')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])"/>
    <classsynopsisinfo role="comment">&InheritedMethods;</classsynopsisinfo>
    <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.evwatcher')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
   </classsynopsis>
<!-- }}} -->
  </section>
<!-- {{{ EvTimer properties -->
  <section xml:id="evtimer.props">
   &reftitle.properties;
   <variablelist>
    <varlistentry xml:id="evtimer.props.repeat">
     <term>
      <varname>repeat</varname>
     </term>
     <listitem>
      <para>
       If repeat is
       <constant>0.0</constant>
       , then it will automatically be stopped once the timeout is reached. If
       it is positive, then the timer will automatically be configured to
       trigger again every repeat seconds later, until stopped manually.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry xml:id="evtimer.props.remaining">
     <term>
      <varname>remaining</varname>
     </term>
     <listitem>
      <para>
       Returns the remaining time until a timer fires. If the timer is active,
       then this time is relative to the current event loop time, otherwise
       it&apos;s the timeout value currently configured.
      </para>
      <para>
       That is, after instanciating an
       <classname>EvTimer</classname>
       with an
       <parameter>after</parameter>
       value of
       <constant>5.0</constant>
       and
       <parameter>repeat</parameter>
       value of
       <constant>7.0</constant>
       ,
       <varname>remaining</varname>
       returns
       <constant>5.0</constant>
       . When the timer is started and one second passes,
       <varname>remaining</varname>
       will return
       <constant>4.0</constant>
       . When the timer expires and is restarted, it will return roughly
       <constant>7.0</constant>
       (likely slightly less as callback invocation takes some time too), and
       so on.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </section>
<!-- }}} -->
 </partintro>

 &reference.ev.entities.evtimer;

</phpdoc:classref>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
