Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > by-pkgid > ad1ba1135a9c9eeffc2e538163e00373 > files > 792

libCommonC++2_1.4-devel-1.4.1-1mdv2007.0.i586.rpm

\section{ost::Timer\-Port Class Reference}
\label{classost_1_1_timer_port}\index{ost::TimerPort@{ost::TimerPort}}
Timer ports are used to provide synchronized timing events when managed under a \char`\"{}service thread\char`\"{} such as Socket\-Service.synchronized millisecond timing for service threads.  


{\tt \#include $<$thread.h$>$}

Inheritance diagram for ost::Timer\-Port::\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2cm]{classost_1_1_timer_port}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Timer\-Port} ()
\begin{CompactList}\small\item\em Create a timer, mark it as inactive, and set the initial \char`\"{}start\char`\"{} time to the creation time of the timer object. \item\end{CompactList}\item 
void {\bf set\-Timer} ({\bf timeout\_\-t} timeout=0)
\begin{CompactList}\small\item\em 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. \item\end{CompactList}\item 
void {\bf inc\-Timer} ({\bf timeout\_\-t} timeout)
\begin{CompactList}\small\item\em Set a timeout based on the current time reference value either from object creation or the last {\bf set\-Timer()}{\rm (p.\,\pageref{classost_1_1_timer_port_32b59a072fe60d94251a53579b3ca17f})}. \item\end{CompactList}\item 
void {\bf end\-Timer} (void)
\begin{CompactList}\small\item\em This is used to \char`\"{}disable\char`\"{} the service thread from expiring the timer object. \item\end{CompactList}\item 
{\bf timeout\_\-t} {\bf get\-Timer} (void) const 
\begin{CompactList}\small\item\em This is used by service threads to determine how much time remains before the timer expires based on a timeout specified in {\bf set\-Timer()}{\rm (p.\,\pageref{classost_1_1_timer_port_32b59a072fe60d94251a53579b3ca17f})} or {\bf inc\-Timer()}{\rm (p.\,\pageref{classost_1_1_timer_port_b2c732120c3bb09e8d38a87b7443906d})}. \item\end{CompactList}\item 
{\bf timeout\_\-t} {\bf get\-Elapsed} (void) const 
\begin{CompactList}\small\item\em This is used to determine how much time has elapsed since a timer port set\-Timer benchmark time was initially set. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Timer ports are used to provide synchronized timing events when managed under a \char`\"{}service thread\char`\"{} such as Socket\-Service.synchronized millisecond timing for service threads. 

This is made into a stand-alone base class since other derived libraries (such as the serial handlers) may also use the pooled \char`\"{}service thread\char`\"{} model and hence also require this code for managing timing.

\begin{Desc}
\item[Author:]David Sugar $<${\tt dyfet@ostel.com}$>$ \end{Desc}




\subsection{Constructor \& Destructor Documentation}
\index{ost::TimerPort@{ost::Timer\-Port}!TimerPort@{TimerPort}}
\index{TimerPort@{TimerPort}!ost::TimerPort@{ost::Timer\-Port}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Timer\-Port::Timer\-Port ()}\label{classost_1_1_timer_port_d9ecc3aa1d6c62ac2e54e3e725d0c2c2}


Create a timer, mark it as inactive, and set the initial \char`\"{}start\char`\"{} time to the creation time of the timer object. 

This allows \char`\"{}inc\-Timer\char`\"{} to initially refer to time delays relative to the original start time of the object. 

\subsection{Member Function Documentation}
\index{ost::TimerPort@{ost::Timer\-Port}!endTimer@{endTimer}}
\index{endTimer@{endTimer}!ost::TimerPort@{ost::Timer\-Port}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Timer\-Port::end\-Timer (void)}\label{classost_1_1_timer_port_9f473745a237d71219096c9a5b440445}


This is used to \char`\"{}disable\char`\"{} the service thread from expiring the timer object. 

It does not effect the reference time from either creation or a {\bf set\-Timer()}{\rm (p.\,\pageref{classost_1_1_timer_port_32b59a072fe60d94251a53579b3ca17f})}. \index{ost::TimerPort@{ost::Timer\-Port}!getElapsed@{getElapsed}}
\index{getElapsed@{getElapsed}!ost::TimerPort@{ost::Timer\-Port}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf timeout\_\-t} ost::Timer\-Port::get\-Elapsed (void) const}\label{classost_1_1_timer_port_c46e765c47dafaac921ed00b40b92018}


This is used to determine how much time has elapsed since a timer port set\-Timer benchmark time was initially set. 

This allows one to use {\bf set\-Timer()}{\rm (p.\,\pageref{classost_1_1_timer_port_32b59a072fe60d94251a53579b3ca17f})} to set the timer to the current time and then measure elapsed time from that point forward.

return time elapsed in milliseconds, or TIMEOUT\_\-INF if inactive. \index{ost::TimerPort@{ost::Timer\-Port}!getTimer@{getTimer}}
\index{getTimer@{getTimer}!ost::TimerPort@{ost::Timer\-Port}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf timeout\_\-t} ost::Timer\-Port::get\-Timer (void) const}\label{classost_1_1_timer_port_7c8c5396ab12d69dd9048e88b0cb125c}


This is used by service threads to determine how much time remains before the timer expires based on a timeout specified in {\bf set\-Timer()}{\rm (p.\,\pageref{classost_1_1_timer_port_32b59a072fe60d94251a53579b3ca17f})} or {\bf inc\-Timer()}{\rm (p.\,\pageref{classost_1_1_timer_port_b2c732120c3bb09e8d38a87b7443906d})}. 

It can also be called after setting a timeout with {\bf inc\-Timer()}{\rm (p.\,\pageref{classost_1_1_timer_port_b2c732120c3bb09e8d38a87b7443906d})} to see if the current timeout has already expired and hence that the application is already delayed and should skip frame(s).

return time remaining in milliseconds, or TIMEOUT\_\-INF if inactive. \index{ost::TimerPort@{ost::Timer\-Port}!incTimer@{incTimer}}
\index{incTimer@{incTimer}!ost::TimerPort@{ost::Timer\-Port}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Timer\-Port::inc\-Timer ({\bf timeout\_\-t} {\em timeout})}\label{classost_1_1_timer_port_b2c732120c3bb09e8d38a87b7443906d}


Set a timeout based on the current time reference value either from object creation or the last {\bf set\-Timer()}{\rm (p.\,\pageref{classost_1_1_timer_port_32b59a072fe60d94251a53579b3ca17f})}. 

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.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em timeout}]delay in milliseconds from reference. \end{description}
\end{Desc}


Reimplemented in {\bf ost::Serial\-Port} {\rm (p.\,\pageref{classost_1_1_serial_port_4fa45b7494efbcd0c1b28a724f93b6b3})}, and {\bf ost::Socket\-Port} {\rm (p.\,\pageref{classost_1_1_socket_port_1a7e2bf9e250ea5dcc9e8416aecfbb13})}.\index{ost::TimerPort@{ost::Timer\-Port}!setTimer@{setTimer}}
\index{setTimer@{setTimer}!ost::TimerPort@{ost::Timer\-Port}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Timer\-Port::set\-Timer ({\bf timeout\_\-t} {\em timeout} = {\tt 0})}\label{classost_1_1_timer_port_32b59a072fe60d94251a53579b3ca17f}


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. 

This can be used to set the starting time of a realtime session.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em timeout}]delay in milliseconds from \char`\"{}now\char`\"{} \end{description}
\end{Desc}


Reimplemented in {\bf ost::Serial\-Port} {\rm (p.\,\pageref{classost_1_1_serial_port_eb008981e1a1d2eff230b231c3ce5d9c})}, and {\bf ost::Socket\-Port} {\rm (p.\,\pageref{classost_1_1_socket_port_c70f9eae6b6b3625c980fa84180e8151})}.

The documentation for this class was generated from the following file:\begin{CompactItemize}
\item 
{\bf thread.h}\end{CompactItemize}