Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

CriticalSectionBlock.H File Reference

#include <critsec.h>

Go to the source code of this file.

Data Structures

class  CriticalSectionBlock

Defines

#define synchronized(cs)   for(CriticalSectionBlock __currentlocked(cs);__currentlocked.checkonce();/* */)


Define Documentation

#define synchronized cs   )     for(CriticalSectionBlock __currentlocked(cs);__currentlocked.checkonce();/* */)
 

cool macro which makes it possible to use the CriticalSectionBlock the way you are used to in Java (..if you are used to java). Basically you use it this way:

 --------------------------------------------------------------------- 
 critsec_t someCriticalSection;
 void foo () {
     // ...
     synchronized (&someCriticalSection) {
         //.. critical section protected with critical section.
         myCriticalDataStructure = 42;
     }
     // ...
 }
 --------------------------------------------------------------------- 
 

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 ?

Author:
Henner Zeller <H.Zeller@acm.org>

Definition at line 131 of file CriticalSectionBlock.H.


Generated on Fri Feb 25 08:02:41 2005 for brickos by  doxygen 1.3.9.1