\section{include/c++/Critical\-Section\-Block.H File Reference}
\label{CriticalSectionBlock_8H}\index{include/c++/CriticalSectionBlock.H@{include/c++/CriticalSectionBlock.H}}
{\tt \#include $<$critsec.h$>$}\par
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
class {\bf Critical\-Section\-Block}
\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf synchronized}(cs)\ for({\bf Critical\-Section\-Block} \_\-\_\-currentlocked(cs);\_\-\_\-currentlocked.checkonce();/$\ast$ $\ast$/)
\end{CompactItemize}


\subsection{Define Documentation}
\index{CriticalSectionBlock.H@{Critical\-Section\-Block.H}!synchronized@{synchronized}}
\index{synchronized@{synchronized}!CriticalSectionBlock.H@{Critical\-Section\-Block.H}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define synchronized(cs)\ for({\bf Critical\-Section\-Block} \_\-\_\-currentlocked(cs);\_\-\_\-currentlocked.checkonce();/$\ast$ $\ast$/)}\label{CriticalSectionBlock_8H_a0}


cool macro which makes it possible to use the {\bf Critical\-Section\-Block}{\rm (p.\,\pageref{classCriticalSectionBlock})} the way you are used to in Java (..if you are used to java). Basically you use it this way:

\small\begin{alltt}
 --------------------------------------------------------------------- 
 critsec\_t someCriticalSection;
 void foo () \{
     // ...
     synchronized (\&someCriticalSection) \{
         //.. critical section protected with critical section.
         myCriticalDataStructure = 42;
     \}
     // ...
 \}
 --------------------------------------------------------------------- 
 \end{alltt}\normalsize 


The implementation of this macro creates a automatic variable within the initialization part of a for-loop which is valid for the lifetime of the block within the curly braces.

BUGS: wastes some CPU cyles for a counter which is neccessary to abuse the for(;;) loop to have this behaviour. Any ideas ?

\begin{Desc}
\item[Author:]Henner Zeller $<${\tt H.Zeller@acm.org}$>$ \end{Desc}


Definition at line 131 of file Critical\-Section\-Block.H.