Download this file
26 lines (24 with data), 653 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 | #pragma once
#include <assert.h>
class CRWSection
{
public:
CRWSection();
~CRWSection();
void WaitToRead();
void WaitToWrite();
void Done();
bool IsWriter() {return ((m_nWaitingWriters > 0) || (m_nActive < 0));}
#if defined (DEBUG) || defined (_DEBUG)
void AssertWriting() {assert((m_nWaitingWriters || (m_nActive < 0)));}
#else
void AssertWriting() {;}
#endif
private:
int m_nWaitingReaders; // Number of readers waiting for access
int m_nWaitingWriters; // Number of writers waiting for access
int m_nActive; // Number of threads accessing the section
CRITICAL_SECTION m_cs;
HANDLE m_hReaders;
HANDLE m_hWriters;
};
|
×
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.