<!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"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.5"/> <title>GNU CommonC++: ost::TimerPort Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">GNU CommonC++ </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.5 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <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 id="navrow2" class="tabs2"> <ul class="tablist"> <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 id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespaceost.html">ost</a></li><li class="navelem"><a class="el" href="classost_1_1_timer_port.html">TimerPort</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> | <a href="classost_1_1_timer_port-members.html">List of all members</a> </div> <div class="headertitle"> <div class="title">ost::TimerPort Class Reference</div> </div> </div><!--header--> <div class="contents"> <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 ports...">SocketService</a>. <a href="classost_1_1_timer_port.html#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="dyncontent"> <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" title="The serial port is an internal class which is attached to and then serviced by a specified SerialServ..." alt="ost::SerialPort" shape="rect" coords="0,56,95,80"/> <area href="classost_1_1_socket_port.html" title="The socket port is an internal class which is attached to and then serviced by a specific SocketServi..." alt="ost::SocketPort" shape="rect" coords="105,56,200,80"/> </map> </div></div> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr class="memitem:ad9ecc3aa1d6c62ac2e54e3e725d0c2c2"><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 class="memdesc:ad9ecc3aa1d6c62ac2e54e3e725d0c2c2"><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">More...</a><br/></td></tr> <tr class="separator:ad9ecc3aa1d6c62ac2e54e3e725d0c2c2"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a32b59a072fe60d94251a53579b3ca17f"><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 class="memdesc:a32b59a072fe60d94251a53579b3ca17f"><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">More...</a><br/></td></tr> <tr class="separator:a32b59a072fe60d94251a53579b3ca17f"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ab2c732120c3bb09e8d38a87b7443906d"><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 class="memdesc:ab2c732120c3bb09e8d38a87b7443906d"><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 activate the timer...">setTimer()</a>. <a href="#ab2c732120c3bb09e8d38a87b7443906d">More...</a><br/></td></tr> <tr class="separator:ab2c732120c3bb09e8d38a87b7443906d"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a86a366beb2159e41f5a1eb5daecf785b"><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 class="memdesc:a86a366beb2159e41f5a1eb5daecf785b"><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 activate the timer...">setTimer()</a>. <a href="#a86a366beb2159e41f5a1eb5daecf785b">More...</a><br/></td></tr> <tr class="separator:a86a366beb2159e41f5a1eb5daecf785b"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a309d9061cc2b48931dee1adbf3ff6a7e"><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 class="memdesc:a309d9061cc2b48931dee1adbf3ff6a7e"><td class="mdescLeft"> </td><td class="mdescRight">Sleep until the current timer expires. <a href="#a309d9061cc2b48931dee1adbf3ff6a7e">More...</a><br/></td></tr> <tr class="separator:a309d9061cc2b48931dee1adbf3ff6a7e"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a9f473745a237d71219096c9a5b440445"><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 class="memdesc:a9f473745a237d71219096c9a5b440445"><td class="mdescLeft"> </td><td class="mdescRight">This is used to "disable" the service thread from expiring the timer object. <a href="#a9f473745a237d71219096c9a5b440445">More...</a><br/></td></tr> <tr class="separator:a9f473745a237d71219096c9a5b440445"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a7c8c5396ab12d69dd9048e88b0cb125c"><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 class="memdesc:a7c8c5396ab12d69dd9048e88b0cb125c"><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 activate the timer...">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 or the last setTi...">incTimer()</a>. <a href="#a7c8c5396ab12d69dd9048e88b0cb125c">More...</a><br/></td></tr> <tr class="separator:a7c8c5396ab12d69dd9048e88b0cb125c"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ac46e765c47dafaac921ed00b40b92018"><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 class="memdesc:ac46e765c47dafaac921ed00b40b92018"><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">More...</a><br/></td></tr> <tr class="separator:ac46e765c47dafaac921ed00b40b92018"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><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 ports...">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="section author"><dt>Author</dt><dd>David Sugar <a href="#" onclick="location.href='mai'+'lto:'+'dyf'+'et'+'@os'+'te'+'l.c'+'om'; return false;">dyfet<span style="display: none;">.nosp@m.</span>@ost<span style="display: none;">.nosp@m.</span>el.co<span style="display: none;">.nosp@m.</span>m</a> synchronized millisecond timing for service threads. </dd></dl> </div><h2 class="groupheader">Constructor & Destructor Documentation</h2> <a class="anchor" id="ad9ecc3aa1d6c62ac2e54e3e725d0c2c2"></a> <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> <h2 class="groupheader">Member Function Documentation</h2> <a class="anchor" id="a86a366beb2159e41f5a1eb5daecf785b"></a> <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 activate the timer...">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 class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">timeout</td><td>delay in milliseconds from reference. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a9f473745a237d71219096c9a5b440445"></a> <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 activate the timer...">setTimer()</a>. </p> </div> </div> <a class="anchor" id="ac46e765c47dafaac921ed00b40b92018"></a> <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 activate the timer...">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> <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 activate the timer...">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 or the last setTi...">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 or the last setTi...">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> <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 activate the timer...">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 class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">timeout</td><td>delay in milliseconds from reference. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a32b59a072fe60d94251a53579b3ca17f"></a> <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 class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">timeout</td><td>delay in milliseconds from "now" </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a309d9061cc2b48931dee1adbf3ff6a7e"></a> <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><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Thu Oct 17 2013 23:24:58 for GNU CommonC++ by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.5 </small></address> </body> </html>