1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<reference xml:id="class.evtimer" role="class" 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
<literal>10</literal>
seconds, then it will normally trigger at exactly
<literal>10</literal>
second intervals. If, however, the script cannot keep up with the timer
because it takes longer than those
<literal>10</literal>
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
<literal>0.0</literal>,
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's the timeout value currently configured.
</para>
<para>
That is, after instanciating an
<classname>EvTimer</classname>
with an
<parameter>after</parameter>
value of
<literal>5.0</literal>
and
<parameter>repeat</parameter>
value of
<literal>7.0</literal>,
<varname>remaining</varname>
returns
<literal>5.0</literal>.
When the timer is started and one second passes,
<varname>remaining</varname>
will return
<literal>4.0</literal>.
When the timer expires and is restarted, it will return roughly
<literal>7.0</literal>
(likely slightly less as callback invocation takes some time too), and
so on.
</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<!-- }}} -->
</partintro>
&reference.ev.entities.evtimer;
</reference>
<!-- 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
-->
|