Sophie

Sophie

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

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

\section{ost::Mutex\-Lock Class Reference}
\label{classost_1_1_mutex_lock}\index{ost::MutexLock@{ost::MutexLock}}
The {\bf Mutex\-Lock}{\rm (p.\,\pageref{classost_1_1_mutex_lock})} class is used to protect a section of code so that at any given time only a single thread can perform the protected operation.Mutex automatic locker for protected access.  


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

\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Mutex\-Lock} ({\bf Mutex} \&\_\-mutex)
\begin{CompactList}\small\item\em Acquire the mutex. \item\end{CompactList}\item 
{\bf $\sim$Mutex\-Lock} ()
\begin{CompactList}\small\item\em Release the mutex automatically. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
The {\bf Mutex\-Lock}{\rm (p.\,\pageref{classost_1_1_mutex_lock})} class is used to protect a section of code so that at any given time only a single thread can perform the protected operation.Mutex automatic locker for protected access. 

It use {\bf Mutex}{\rm (p.\,\pageref{classost_1_1_mutex})} to protect operation. Using this class is usefull and exception safe. The mutex that has been locked is automatically released when the function call stack falls out of scope, so one doesnt have to remember to unlock the mutex at each function return.

A common use is

void func\_\-to\_\-protect() \{ {\bf Mutex\-Lock}{\rm (p.\,\pageref{classost_1_1_mutex_lock})} lock(mutex); ... operation ... \}

NOTE: do not declare variable as \char`\"{}Mutex\-Lock (mutex)\char`\"{}, the mutex will be released at statement end.

\begin{Desc}
\item[Author:]Frediano Ziglio $<${\tt freddy77@angelfire.com}$>$ \end{Desc}




\subsection{Constructor \& Destructor Documentation}
\index{ost::MutexLock@{ost::Mutex\-Lock}!MutexLock@{MutexLock}}
\index{MutexLock@{MutexLock}!ost::MutexLock@{ost::Mutex\-Lock}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Mutex\-Lock::Mutex\-Lock ({\bf Mutex} \& {\em \_\-mutex})\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_mutex_lock_edb21cfad9b0f1200d055fb69efa2546}


Acquire the mutex. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-mutex}]reference to mutex to aquire. \end{description}
\end{Desc}
\index{ost::MutexLock@{ost::Mutex\-Lock}!~MutexLock@{$\sim$MutexLock}}
\index{~MutexLock@{$\sim$MutexLock}!ost::MutexLock@{ost::Mutex\-Lock}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Mutex\-Lock::$\sim$Mutex\-Lock ()\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_mutex_lock_58bba3406d89b40c8bd3e9ac389b920c}


Release the mutex automatically. 



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