Richard Boegli's CnC_Generals_Zero_Hour Fork
WIP
This is documentation of Richard Boegil's Zero Hour Fork
Loading...
Searching...
No Matches
critsec.h
Go to the documentation of this file.
1
/*
2
** Command & Conquer Generals Zero Hour(tm)
3
** Copyright 2025 Electronic Arts Inc.
4
**
5
** This program is free software: you can redistribute it and/or modify
6
** it under the terms of the GNU General Public License as published by
7
** the Free Software Foundation, either version 3 of the License, or
8
** (at your option) any later version.
9
**
10
** This program is distributed in the hope that it will be useful,
11
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
** GNU General Public License for more details.
14
**
15
** You should have received a copy of the GNU General Public License
16
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef CRITSEC_HEADER
20
#define CRITSEC_HEADER
21
22
#include "
wstypes.h
"
23
#ifdef _WIN32
24
#include <windows.h>
25
#include <winbase.h>
26
#elif defined(_UNIX)
27
#include <pthread.h>
28
#include <errno.h>
29
#endif
30
31
// Windows headers have a tendency to redefine IN
32
#ifdef IN
33
#undef IN
34
#endif
35
#define IN const
36
37
//
38
// Critical Section built either on a POSIX Mutex, or a Win32 Critical Section
39
//
40
// POSIX version is done by keeping a thread_id and a reference count. Win32 version
41
// just calls the built in functions.
42
//
43
class
CritSec
44
{
45
public
:
46
CritSec
();
47
~CritSec
();
48
49
sint32
lock
(
int
*refcount=
NULL
)
RO
;
50
sint32
unlock
(
void
)
RO
;
51
52
protected
:
53
#ifdef _WIN32
54
mutable
CRITICAL_SECTION CritSec_;
55
#else
56
mutable
pthread_mutex_t
Mutex_
;
// Mutex lock
57
mutable
pthread_t
ThreadId_
;
// Owner of mutex
58
mutable
int
RefCount_
;
// Reference count
59
#endif
60
};
61
62
#endif
NULL
#define NULL
Definition
BaseType.h:92
sint32
signed long sint32
Definition
bittype.h:51
CritSec::CritSec
CritSec()
Definition
critsec.cpp:25
CritSec::unlock
sint32 unlock(void) RO
Definition
critsec.cpp:96
CritSec::ThreadId_
pthread_t ThreadId_
Definition
critsec.h:57
CritSec::Mutex_
pthread_mutex_t Mutex_
Definition
critsec.h:56
CritSec::lock
sint32 lock(int *refcount=NULL) RO
Definition
critsec.cpp:52
CritSec::RefCount_
int RefCount_
Definition
critsec.h:58
CritSec::~CritSec
~CritSec()
Definition
critsec.cpp:35
wstypes.h
RO
#define RO
Definition
wstypes.h:92
Code
Tools
mangler
wlib
critsec.h
Generated by
1.13.2