Main Page
Related Pages
Modules
Classes
Files
File List
File Members
CriticalSectionBlock.H
Go to the documentation of this file.
1
// The contents of this file are subject to the Mozilla Public License
2
// Version 1.0 (the "License"); you may not use this file except in
3
// compliance with the License. You may obtain a copy of the License
4
// at http://www.mozilla.org/MPL/
5
//
6
// Software distributed under the License is distributed on an "AS IS"
7
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
8
// the License for the specific language governing rights and
9
// limitations under the License.
10
//
11
// Contributor Henner Zeller <H.Zeller@acm.org>
12
13
#ifndef __CRITICALSECTIONBLOCK_H
14
#define __CRITICALSECTIONBLOCK_H
15
16
#include <
critsec.h
>
17
70
class
CriticalSectionBlock
{
71
private
:
72
critsec_t
*_critsec;
77
char
_checkonceHackCounter;
78
79
public
:
83
CriticalSectionBlock
(
critsec_t
*critsec)
84
: _critsec(critsec),
85
_checkonceHackCounter(1)
86
{
87
enter_critical_section
(_critsec);
88
}
89
93
inline
bool
checkonce
() {
return
_checkonceHackCounter-- > 0; }
94
98
~CriticalSectionBlock
() {
99
leave_critical_section
(_critsec);
100
}
101
};
102
131
#define synchronized(cs) for(CriticalSectionBlock __currentlocked(cs);__currentlocked.checkonce();
/* */
)
132
133
/*
134
* Local variables:
135
* c-basic-offset: 8
136
* End:
137
*/
138
139
#endif
/* __CRITICALSECTIONBLOCK_H */
brickOS
is released under the
Mozilla Public License
.
Original code copyright 1998-2005 by the authors.
Generated on Sat Mar 15 2014 11:28:19 for brickOS C++ by
1.8.1.2