CriticalSectionBlock.H File Reference
#include <critsec.h>
Include dependency graph for CriticalSectionBlock.H:

Go to the source code of this file.

Classes

class  CriticalSectionBlock
 A CriticalSectionBlock locks a critical section for the lifetime of the CriticalSectionBlock. More...
 

Macros

#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).
 

Macro Definition Documentation

◆ synchronized

#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.Zel.nosp@m.ler@.nosp@m.acm.o.nosp@m.rg

Definition at line 131 of file CriticalSectionBlock.H.


brickOS is released under the Mozilla Public License.
Original code copyright 1998-2005 by the authors.

Generated for brickOS Kernel Developer by doxygen 1.9.8