⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classptimer.html

📁 pwlib开发文档
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>PTimer class Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center><hr><h1>PTimer Class Reference</h1><code>#include &lt;<a class="el" href="timer_8h-source.html">timer.h</a>&gt;</code><p><p>Inheritance diagram for PTimer:<p><center><img src="classPTimer.png" usemap="#PTimer_map" border="0" alt=""></center><map name="PTimer_map"><area href="classPTimeInterval.html" alt="PTimeInterval" shape="rect" coords="0,56,88,80"><area href="classPObject.html" alt="PObject" shape="rect" coords="0,0,88,24"></map><a href="classPTimer-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Public Methods</h2></td></tr><tr><td colspan="2"><div class="groupHeader">Construction</div></td></tr><tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z457_0">PTimer</a> (long <a class="el" href="classPTimeInterval.html#n0">milliseconds</a>=0, int seconds=0, int minutes=0, int hours=0, int days=0)</td></tr><tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z457_1">PTimer</a> (const <a class="el" href="classPTimeInterval.html">PTimeInterval</a> &amp;time)</td></tr><tr><td nowrap align=right valign=top>PTimer &amp;&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z457_2">operator=</a> (DWORD <a class="el" href="classPTimeInterval.html#n0">milliseconds</a>)</td></tr><tr><td nowrap align=right valign=top>PTimer &amp;&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z457_3">operator=</a> (const <a class="el" href="classPTimeInterval.html">PTimeInterval</a> &amp;time)</td></tr><tr><td nowrap align=right valign=top>virtual&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z457_4">~PTimer</a> ()</td></tr><tr><td colspan="2"><div class="groupHeader">Control functions</div></td></tr><tr><td nowrap align=right valign=top>virtual void&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z459_0">SetInterval</a> (PInt64 <a class="el" href="classPTimeInterval.html#n0">milliseconds</a>=0, long seconds=0, long minutes=0, long hours=0, int days=0)</td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z459_1">RunContinuous</a> (const <a class="el" href="classPTimeInterval.html">PTimeInterval</a> &amp;time)</td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z459_2">Stop</a> ()</td></tr><tr><td nowrap align=right valign=top>BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z459_3">IsRunning</a> () const</td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z459_4">Pause</a> ()</td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z459_5">Resume</a> ()</td></tr><tr><td nowrap align=right valign=top>BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z459_6">IsPaused</a> () const</td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z459_7">Reset</a> ()</td></tr><tr><td nowrap align=right valign=top>const <a class="el" href="classPTimeInterval.html">PTimeInterval</a> &amp;&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z459_8">GetResetTime</a> () const</td></tr><tr><td colspan="2"><div class="groupHeader">Notification functions</div></td></tr><tr><td nowrap align=right valign=top>virtual void&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z461_0">OnTimeout</a> ()</td></tr><tr><td nowrap align=right valign=top>const <a class="el" href="classPNotifier.html">PNotifier</a> &amp;&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z461_1">GetNotifier</a> () const</td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z461_2">SetNotifier</a> (const <a class="el" href="classPNotifier.html">PNotifier</a> &amp;func)</td></tr><tr><td colspan=2><br><h2>Static Public Methods</h2></td></tr><tr><td colspan="2"><div class="groupHeader">Global real time functions</div></td></tr><tr><td nowrap align=right valign=top><a class="el" href="classPTimeInterval.html">PTimeInterval</a>&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z463_0">Tick</a> ()</td></tr><tr><td nowrap align=right valign=top>unsigned&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#z463_1">Resolution</a> ()</td></tr><tr><td colspan=2><br><h2>Friends</h2></td></tr><tr><td nowrap align=right valign=top>class&nbsp;</td><td valign=bottom><a class="el" href="classPTimer.html#l0">PTimerList</a></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>A class representing a system timer. The time interval ancestor value is the amount of time left in the timer.<p>A timer on completion calls the virtual function <a class="el" href="classPTimer.html#z461_0">OnTimeout()</a>#. This will in turn call the callback function provided by the instance. The user may either override the virtual function or set a callback as desired.<p>A list of active timers is maintained by the applications PProcess#  instance and the timeout functions are executed in the context of a single thread of execution. There are many consequences of this: only one timeout function can be executed at a time and thus a user should not execute a lot of code in the timeout call-back functions or it will dealy the timely execution of other timers call-back functions.<p>Also timers are not very accurate in sub-second delays, even though you can set the timer in milliseconds, its accuracy is only to -0/+250 ms. Even more (potentially MUCH more) if there are delays in the user call-back functions.<p>Another trap is you cannot destroy a timer in its own call-back. There is code to cause an assert if you try but it is very easy to accidentally do this when you delete an object that contains an onject that contains the timer!<p>Finally static timers cause race conditions on start up and termination and should be avoided. <p><hr><h2>Constructor &amp; Destructor Documentation</h2><a name="z457_0" doxytag="PTimer::PTimer"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> PTimer::PTimer </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">long&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>milliseconds</em> = 0, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>int&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>seconds</em> = 0, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>int&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>minutes</em> = 0, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>int&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>hours</em> = 0, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>int&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>days</em> = 0</td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Create a new timer object and start it in one shot mode for the specified amount of time. If the time was zero milliseconds then the timer is {\bf not} started, ie the callback function is not executed immediately. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>seconds</em>&nbsp;</td><td>Number of milliseconds for timer. </td></tr><tr><td valign=top><em>minutes</em>&nbsp;</td><td>Number of seconds for timer. </td></tr><tr><td valign=top><em>hours</em>&nbsp;</td><td>Number of minutes for timer. </td></tr><tr><td valign=top><em>days</em>&nbsp;</td><td>Number of hours for timer. Number of days for timer. </td></tr></table></dl>    </td>  </tr></table><a name="z457_1" doxytag="PTimer::PTimer"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> PTimer::PTimer </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">const <a class="el" href="classPTimeInterval.html">PTimeInterval</a> &amp;&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp; <em>time</em>          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>time</em>&nbsp;</td><td>New time interval for timer. </td></tr></table></dl>    </td>  </tr></table><a name="z457_4" doxytag="PTimer::~PTimer"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> virtual PTimer::~PTimer </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp;          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap><code> [virtual]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Destroy the timer object, removing it from the applications timer list if it was running.     </td>  </tr></table><hr><h2>Member Function Documentation</h2><a name="z461_1" doxytag="PTimer::GetNotifier"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> PINLINE const <a class="el" href="classPNotifier.html">PNotifier</a> &amp; PTimer::GetNotifier </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp;          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Get the current call back function that is called whenever the timer expires. This is called by the <a class="el" href="classPTimer.html#z461_0">OnTimeout()</a># function.<p><dl compact><dt><b>Returns: </b></dt><dd> current notifier for the timer. </dl>    </td>  </tr></table><a name="z459_8" doxytag="PTimer::GetResetTime"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> PINLINE const <a class="el" href="classPTimeInterval.html">PTimeInterval</a> &amp; PTimer::GetResetTime </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp;          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Get the time this timer was set to initially.     </td>  </tr></table><a name="z459_6" doxytag="PTimer::IsPaused"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> PINLINE BOOL PTimer::IsPaused </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp;          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Determine if the timer is currently paused.<p><dl compact><dt><b>Returns: </b></dt><dd> TRUE if timer paused. </dl>    </td>  </tr></table><a name="z459_3" doxytag="PTimer::IsRunning"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> PINLINE BOOL PTimer::IsRunning </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp;          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Determine if the timer is currently running. This really is only useful for one shot timers as repeating timers are always running.<p><dl compact><dt><b>Returns: </b></dt><dd> TRUE if timer is still counting. </dl>    </td>  </tr></table><a name="z461_0" doxytag="PTimer::OnTimeout"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> virtual void PTimer::OnTimeout </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp;          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap><code> [virtual]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>This function is called on time out. That is when the system timer processing decrements the timer from a positive value to less than or equal to zero. The interval is then reset to zero and the function called.<p>Please note that the application should not execute large amounts of code in this call back or the accuracy of ALL timers can be severely impacted.<p>The default behaviour of this function is to call the PNotifier#  callback function.     </td>  </tr></table><a name="z457_3" doxytag="PTimer::operator="></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> PTimer&amp; PTimer::operator= </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">const <a class="el" href="classPTimeInterval.html">PTimeInterval</a> &amp;&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp; <em>time</em>          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p><dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>time</em>&nbsp;</td><td>New time interval for timer. </td></tr></table></dl>    </td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -