<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>GNU CommonC++: ost::TimerPort Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="classes.html"><span>Class Index</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="namespaceost.html">ost</a>::<a class="el" href="classost_1_1_timer_port.html">TimerPort</a> </div> </div> <div class="contents"> <h1>ost::TimerPort Class Reference</h1><!-- doxytag: class="ost::TimerPort" --> <p>Timer ports are used to provide synchronized timing events when managed under a "service thread" such as <a class="el" href="classost_1_1_socket_service.html" title="The SocketService is a thread pool object that is meant to service attached socket...">SocketService</a>. <a href="#_details">More...</a></p> <p><code>#include <<a class="el" href="thread_8h_source.html">thread.h</a>></code></p> <div class="dynheader"> Inheritance diagram for ost::TimerPort:</div> <div class="dynsection"> <div class="center"> <img src="classost_1_1_timer_port.png" usemap="#ost::TimerPort_map" alt=""/> <map id="ost::TimerPort_map" name="ost::TimerPort_map"> <area href="classost_1_1_serial_port.html" alt="ost::SerialPort" shape="rect" coords="0,56,95,80"/> <area href="classost_1_1_socket_port.html" alt="ost::SocketPort" shape="rect" coords="105,56,200,80"/> </map> </div> </div> <p><a href="classost_1_1_timer_port-members.html">List of all members.</a></p> <table border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"><h2>Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_timer_port.html#ad9ecc3aa1d6c62ac2e54e3e725d0c2c2">TimerPort</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Create a timer, mark it as inactive, and set the initial "start" time to the creation time of the timer object. <a href="#ad9ecc3aa1d6c62ac2e54e3e725d0c2c2"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_timer_port.html#a32b59a072fe60d94251a53579b3ca17f">setTimer</a> (<a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> timeout=0)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Set a new start time for the object based on when this call is made and optionally activate the timer for a specified number of milliseconds. <a href="#a32b59a072fe60d94251a53579b3ca17f"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_timer_port.html#ab2c732120c3bb09e8d38a87b7443906d">incTimer</a> (<a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> timeout)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Set a timeout based on the current time reference value either from object creation or the last <a class="el" href="classost_1_1_timer_port.html#a32b59a072fe60d94251a53579b3ca17f" title="Set a new start time for the object based on when this call is made and optionally...">setTimer()</a>. <a href="#ab2c732120c3bb09e8d38a87b7443906d"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_timer_port.html#a86a366beb2159e41f5a1eb5daecf785b">decTimer</a> (<a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> timeout)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Adjust a timeout based on the current time reference value either from object creation or the last <a class="el" href="classost_1_1_timer_port.html#a32b59a072fe60d94251a53579b3ca17f" title="Set a new start time for the object based on when this call is made and optionally...">setTimer()</a>. <a href="#a86a366beb2159e41f5a1eb5daecf785b"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_timer_port.html#a309d9061cc2b48931dee1adbf3ff6a7e">sleepTimer</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Sleep until the current timer expires. <a href="#a309d9061cc2b48931dee1adbf3ff6a7e"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_timer_port.html#a9f473745a237d71219096c9a5b440445">endTimer</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">This is used to "disable" the service thread from expiring the timer object. <a href="#a9f473745a237d71219096c9a5b440445"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_timer_port.html#a7c8c5396ab12d69dd9048e88b0cb125c">getTimer</a> (void) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">This is used by service threads to determine how much time remains before the timer expires based on a timeout specified in <a class="el" href="classost_1_1_timer_port.html#a32b59a072fe60d94251a53579b3ca17f" title="Set a new start time for the object based on when this call is made and optionally...">setTimer()</a> or <a class="el" href="classost_1_1_timer_port.html#ab2c732120c3bb09e8d38a87b7443906d" title="Set a timeout based on the current time reference value either from object creation...">incTimer()</a>. <a href="#a7c8c5396ab12d69dd9048e88b0cb125c"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_timer_port.html#ac46e765c47dafaac921ed00b40b92018">getElapsed</a> (void) const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">This is used to determine how much time has elapsed since a timer port setTimer benchmark time was initially set. <a href="#ac46e765c47dafaac921ed00b40b92018"></a><br/></td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>Timer ports are used to provide synchronized timing events when managed under a "service thread" such as <a class="el" href="classost_1_1_socket_service.html" title="The SocketService is a thread pool object that is meant to service attached socket...">SocketService</a>. </p> <p>This is made into a stand-alone base class since other derived libraries (such as the serial handlers) may also use the pooled "service thread" model and hence also require this code for managing timing.</p> <dl class="author"><dt><b>Author:</b></dt><dd>David Sugar <<a href="mailto:dyfet@ostel.com">dyfet@ostel.com</a>> synchronized millisecond timing for service threads. </dd></dl> <hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="ad9ecc3aa1d6c62ac2e54e3e725d0c2c2"></a><!-- doxytag: member="ost::TimerPort::TimerPort" ref="ad9ecc3aa1d6c62ac2e54e3e725d0c2c2" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">ost::TimerPort::TimerPort </td> <td>(</td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Create a timer, mark it as inactive, and set the initial "start" time to the creation time of the timer object. </p> <p>This allows "incTimer" to initially refer to time delays relative to the original start time of the object. </p> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a86a366beb2159e41f5a1eb5daecf785b"></a><!-- doxytag: member="ost::TimerPort::decTimer" ref="a86a366beb2159e41f5a1eb5daecf785b" args="(timeout_t timeout)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void ost::TimerPort::decTimer </td> <td>(</td> <td class="paramtype"><a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> </td> <td class="paramname"> <em>timeout</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Adjust a timeout based on the current time reference value either from object creation or the last <a class="el" href="classost_1_1_timer_port.html#a32b59a072fe60d94251a53579b3ca17f" title="Set a new start time for the object based on when this call is made and optionally...">setTimer()</a>. </p> <p>This reference can be used to time synchronize realtime data over specified intervals and force expiration when a new frame should be released in a synchronized manner.</p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>delay in milliseconds from reference. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a9f473745a237d71219096c9a5b440445"></a><!-- doxytag: member="ost::TimerPort::endTimer" ref="a9f473745a237d71219096c9a5b440445" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void ost::TimerPort::endTimer </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>This is used to "disable" the service thread from expiring the timer object. </p> <p>It does not effect the reference time from either creation or a <a class="el" href="classost_1_1_timer_port.html#a32b59a072fe60d94251a53579b3ca17f" title="Set a new start time for the object based on when this call is made and optionally...">setTimer()</a>. </p> </div> </div> <a class="anchor" id="ac46e765c47dafaac921ed00b40b92018"></a><!-- doxytag: member="ost::TimerPort::getElapsed" ref="ac46e765c47dafaac921ed00b40b92018" args="(void) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> ost::TimerPort::getElapsed </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p>This is used to determine how much time has elapsed since a timer port setTimer benchmark time was initially set. </p> <p>This allows one to use <a class="el" href="classost_1_1_timer_port.html#a32b59a072fe60d94251a53579b3ca17f" title="Set a new start time for the object based on when this call is made and optionally...">setTimer()</a> to set the timer to the current time and then measure elapsed time from that point forward.</p> <p>return time elapsed in milliseconds, or TIMEOUT_INF if inactive. </p> </div> </div> <a class="anchor" id="a7c8c5396ab12d69dd9048e88b0cb125c"></a><!-- doxytag: member="ost::TimerPort::getTimer" ref="a7c8c5396ab12d69dd9048e88b0cb125c" args="(void) const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> ost::TimerPort::getTimer </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p>This is used by service threads to determine how much time remains before the timer expires based on a timeout specified in <a class="el" href="classost_1_1_timer_port.html#a32b59a072fe60d94251a53579b3ca17f" title="Set a new start time for the object based on when this call is made and optionally...">setTimer()</a> or <a class="el" href="classost_1_1_timer_port.html#ab2c732120c3bb09e8d38a87b7443906d" title="Set a timeout based on the current time reference value either from object creation...">incTimer()</a>. </p> <p>It can also be called after setting a timeout with <a class="el" href="classost_1_1_timer_port.html#ab2c732120c3bb09e8d38a87b7443906d" title="Set a timeout based on the current time reference value either from object creation...">incTimer()</a> to see if the current timeout has already expired and hence that the application is already delayed and should skip frame(s).</p> <p>return time remaining in milliseconds, or TIMEOUT_INF if inactive. </p> </div> </div> <a class="anchor" id="ab2c732120c3bb09e8d38a87b7443906d"></a><!-- doxytag: member="ost::TimerPort::incTimer" ref="ab2c732120c3bb09e8d38a87b7443906d" args="(timeout_t timeout)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void ost::TimerPort::incTimer </td> <td>(</td> <td class="paramtype"><a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> </td> <td class="paramname"> <em>timeout</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Set a timeout based on the current time reference value either from object creation or the last <a class="el" href="classost_1_1_timer_port.html#a32b59a072fe60d94251a53579b3ca17f" title="Set a new start time for the object based on when this call is made and optionally...">setTimer()</a>. </p> <p>This reference can be used to time synchronize realtime data over specified intervals and force expiration when a new frame should be released in a synchronized manner.</p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>delay in milliseconds from reference. </td></tr> </table> </dd> </dl> <p>Reimplemented in <a class="el" href="classost_1_1_serial_port.html#a4fa45b7494efbcd0c1b28a724f93b6b3">ost::SerialPort</a>, and <a class="el" href="classost_1_1_socket_port.html#a1a7e2bf9e250ea5dcc9e8416aecfbb13">ost::SocketPort</a>.</p> </div> </div> <a class="anchor" id="a32b59a072fe60d94251a53579b3ca17f"></a><!-- doxytag: member="ost::TimerPort::setTimer" ref="a32b59a072fe60d94251a53579b3ca17f" args="(timeout_t timeout=0)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void ost::TimerPort::setTimer </td> <td>(</td> <td class="paramtype"><a class="el" href="thread_8h.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> </td> <td class="paramname"> <em>timeout</em> = <code>0</code></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Set a new start time for the object based on when this call is made and optionally activate the timer for a specified number of milliseconds. </p> <p>This can be used to set the starting time of a realtime session.</p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>delay in milliseconds from "now" </td></tr> </table> </dd> </dl> <p>Reimplemented in <a class="el" href="classost_1_1_serial_port.html#aeb008981e1a1d2eff230b231c3ce5d9c">ost::SerialPort</a>, and <a class="el" href="classost_1_1_socket_port.html#ac70f9eae6b6b3625c980fa84180e8151">ost::SocketPort</a>.</p> </div> </div> <a class="anchor" id="a309d9061cc2b48931dee1adbf3ff6a7e"></a><!-- doxytag: member="ost::TimerPort::sleepTimer" ref="a309d9061cc2b48931dee1adbf3ff6a7e" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void ost::TimerPort::sleepTimer </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Sleep until the current timer expires. </p> <p>This is useful in time syncing realtime periodic tasks. </p> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="thread_8h_source.html">thread.h</a></li> </ul> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Fri Nov 12 09:55:48 2010 for GNU CommonC++ by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>