Sophie

Sophie

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

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

\section{ost::Conditional Class Reference}
\label{classost_1_1_conditional}\index{ost::Conditional@{ost::Conditional}}
A conditional variable synchcronization object for one to one and one to many signal and control events between processes.conditional.  


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

Inheritance diagram for ost::Conditional::\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=3cm]{classost_1_1_conditional}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Conditional} (const char $\ast$id=NULL)
\begin{CompactList}\small\item\em Create an instance of a conditional. \item\end{CompactList}\item 
virtual {\bf $\sim$Conditional} ()
\begin{CompactList}\small\item\em Destroy the conditional. \item\end{CompactList}\item 
void {\bf signal} (bool broadcast)
\begin{CompactList}\small\item\em Signal a conditional object and a waiting threads. \item\end{CompactList}\item 
bool {\bf wait} ({\bf timeout\_\-t} timer=0, bool locked=false)
\begin{CompactList}\small\item\em Wait to be signaled from another thread. \item\end{CompactList}\item 
void {\bf enter\-Mutex} (void)
\begin{CompactList}\small\item\em Locks the conditional's mutex for this thread. \item\end{CompactList}\item 
void {\bf lock} (void)
\begin{CompactList}\small\item\em In the future we will use lock in place of enter\-Mutex since the conditional composite is not a recursive mutex, and hence using enter\-Mutex may cause confusion in expectation with the behavior of the {\bf Mutex}{\rm (p.\,\pageref{classost_1_1_mutex})} class. \item\end{CompactList}\item 
bool {\bf try\-Enter\-Mutex} (void)
\begin{CompactList}\small\item\em Tries to lock the conditional for the current thread. \item\end{CompactList}\item 
bool {\bf test} (void)
\item 
void {\bf leave\-Mutex} (void)
\begin{CompactList}\small\item\em Leaving a mutex frees that mutex for use by another thread. \item\end{CompactList}\item 
void {\bf unlock} (void)
\end{CompactItemize}


\subsection{Detailed Description}
A conditional variable synchcronization object for one to one and one to many signal and control events between processes.conditional. 

{\bf Conditional}{\rm (p.\,\pageref{classost_1_1_conditional})} variables may wait for and receive signals to notify when to resume or perform operations. Multiple waiting threads may be woken with a broadcast signal.

\begin{Desc}
\item[Warning:]While this class inherits from {\bf Mutex}{\rm (p.\,\pageref{classost_1_1_mutex})}, the methods of the class {\bf Conditional}{\rm (p.\,\pageref{classost_1_1_conditional})} just handle the system conditional variable, so the user is responsible for calling enter\-Mutex and leave\-Mutex so as to avoid race conditions. Another thing to note is that if you have several threads waiting on one condition, not uncommon in thread pools, each thread must take care to manually unlock the mutex if cancellation occurs. Otherwise the first thread cancelled will deadlock the rest of the thread.\end{Desc}
\begin{Desc}
\item[Author:]David Sugar \end{Desc}
\begin{Desc}
\item[{\bf Todo}]implement in win32 \end{Desc}




\subsection{Constructor \& Destructor Documentation}
\index{ost::Conditional@{ost::Conditional}!Conditional@{Conditional}}
\index{Conditional@{Conditional}!ost::Conditional@{ost::Conditional}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Conditional::Conditional (const char $\ast$ {\em id} = {\tt NULL})}\label{classost_1_1_conditional_7d7009cab2b814c82b41d8682a6ebff0}


Create an instance of a conditional. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em id}]name of conditional, optional for deadlock testing. \end{description}
\end{Desc}
\index{ost::Conditional@{ost::Conditional}!~Conditional@{$\sim$Conditional}}
\index{~Conditional@{$\sim$Conditional}!ost::Conditional@{ost::Conditional}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual ost::Conditional::$\sim$Conditional ()\hspace{0.3cm}{\tt  [virtual]}}\label{classost_1_1_conditional_9772a4c8e522a010a37c63c5ee078384}


Destroy the conditional. 



\subsection{Member Function Documentation}
\index{ost::Conditional@{ost::Conditional}!enterMutex@{enterMutex}}
\index{enterMutex@{enterMutex}!ost::Conditional@{ost::Conditional}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Conditional::enter\-Mutex (void)}\label{classost_1_1_conditional_e3fd225eeae79c24eb7f521f285e8289}


Locks the conditional's mutex for this thread. 

Remember that Conditional's mutex is NOT a recursive mutex!

\begin{Desc}
\item[See also:]{\bf leave\-Mutex}{\rm (p.\,\pageref{classost_1_1_conditional_cc29112f68c34a9844b3c3dad0d03603})} \end{Desc}
\index{ost::Conditional@{ost::Conditional}!leaveMutex@{leaveMutex}}
\index{leaveMutex@{leaveMutex}!ost::Conditional@{ost::Conditional}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Conditional::leave\-Mutex (void)}\label{classost_1_1_conditional_cc29112f68c34a9844b3c3dad0d03603}


Leaving a mutex frees that mutex for use by another thread. 

\begin{Desc}
\item[See also:]{\bf enter\-Mutex}{\rm (p.\,\pageref{classost_1_1_conditional_e3fd225eeae79c24eb7f521f285e8289})} \end{Desc}
\index{ost::Conditional@{ost::Conditional}!lock@{lock}}
\index{lock@{lock}!ost::Conditional@{ost::Conditional}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Conditional::lock (void)\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_conditional_2a3bf89c582dad8ba7e81370fd361668}


In the future we will use lock in place of enter\-Mutex since the conditional composite is not a recursive mutex, and hence using enter\-Mutex may cause confusion in expectation with the behavior of the {\bf Mutex}{\rm (p.\,\pageref{classost_1_1_mutex})} class. 

\begin{Desc}
\item[See also:]{\bf enter\-Mutex}{\rm (p.\,\pageref{classost_1_1_conditional_e3fd225eeae79c24eb7f521f285e8289})} \end{Desc}
\index{ost::Conditional@{ost::Conditional}!signal@{signal}}
\index{signal@{signal}!ost::Conditional@{ost::Conditional}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Conditional::signal (bool {\em broadcast})}\label{classost_1_1_conditional_80822e8493bafb68bac637bbf5fe772d}


Signal a conditional object and a waiting threads. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em broadcast}]this signal to all waiting threads if true. \end{description}
\end{Desc}
\index{ost::Conditional@{ost::Conditional}!test@{test}}
\index{test@{test}!ost::Conditional@{ost::Conditional}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool ost::Conditional::test (void)\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_conditional_507839fac82a32f946fa5f87d41bef28}


\index{ost::Conditional@{ost::Conditional}!tryEnterMutex@{tryEnterMutex}}
\index{tryEnterMutex@{tryEnterMutex}!ost::Conditional@{ost::Conditional}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool ost::Conditional::try\-Enter\-Mutex (void)}\label{classost_1_1_conditional_dcd3f704ef27fff5501a42185a09471f}


Tries to lock the conditional for the current thread. 

Behaves like {\bf enter\-Mutex}{\rm (p.\,\pageref{classost_1_1_conditional_e3fd225eeae79c24eb7f521f285e8289})} , except that it doesn't block the calling thread.

\begin{Desc}
\item[Returns:]true if locking the mutex was succesful otherwise false\end{Desc}
\begin{Desc}
\item[See also:]{\bf enter\-Mutex}{\rm (p.\,\pageref{classost_1_1_conditional_e3fd225eeae79c24eb7f521f285e8289})} 

{\bf leave\-Mutex}{\rm (p.\,\pageref{classost_1_1_conditional_cc29112f68c34a9844b3c3dad0d03603})} \end{Desc}
\index{ost::Conditional@{ost::Conditional}!unlock@{unlock}}
\index{unlock@{unlock}!ost::Conditional@{ost::Conditional}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Conditional::unlock (void)\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_conditional_8b6126bbb6e58c1b8ef937bebf4af222}


\index{ost::Conditional@{ost::Conditional}!wait@{wait}}
\index{wait@{wait}!ost::Conditional@{ost::Conditional}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool ost::Conditional::wait ({\bf timeout\_\-t} {\em timer} = {\tt 0}, bool {\em locked} = {\tt false})}\label{classost_1_1_conditional_2cac07a385596391b0fc8c15b8a598e5}


Wait to be signaled from another thread. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em timer}]time period to wait. \item[{\em locked}]flag if already locked the mutex. \end{description}
\end{Desc}


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