OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
CStdCSecEx Class Reference

#include <StdSync.h>

Inheritance diagram for CStdCSecEx:
[legend]
Collaboration diagram for CStdCSecEx:
[legend]

Public Member Functions

 CStdCSecEx ()
 
 CStdCSecEx (CStdCSecExCallback *pCallb)
 
 ~CStdCSecEx () override=default
 
void Enter () override
 
void Leave () override
 
void EnterShared ()
 
void LeaveShared ()
 

Protected Attributes

long lShareCnt {0}
 
CStdEvent ShareFreeEvent
 
CStdCSecExCallbackpCallbClass {nullptr}
 

Detailed Description

Definition at line 190 of file StdSync.h.

Constructor & Destructor Documentation

CStdCSecEx::CStdCSecEx ( )
inline

Definition at line 193 of file StdSync.h.

194  : ShareFreeEvent(false)
195  { }
CStdEvent ShareFreeEvent
Definition: StdSync.h:205
CStdCSecEx::CStdCSecEx ( CStdCSecExCallback pCallb)
inline

Definition at line 196 of file StdSync.h.

197  : lShareCnt(0), ShareFreeEvent(false), pCallbClass(pCallb)
198  { }
long lShareCnt
Definition: StdSync.h:203
CStdCSecExCallback * pCallbClass
Definition: StdSync.h:207
CStdEvent ShareFreeEvent
Definition: StdSync.h:205
CStdCSecEx::~CStdCSecEx ( )
overridedefault

Member Function Documentation

void CStdCSecEx::Enter ( )
inlineoverridevirtual

Reimplemented from CStdCSec.

Definition at line 212 of file StdSync.h.

References CStdCSec::Enter(), INFINITE, CStdCSec::Leave(), CStdEvent::Reset(), and CStdEvent::WaitFor().

213  {
214  // lock
215  CStdCSec::Enter();
216  // wait for share-free
217  while (lShareCnt)
218  {
219  // reset event
221  // leave section for waiting
222  CStdCSec::Leave();
223  // wait
225  // reenter section
226  CStdCSec::Enter();
227  }
228  }
void Reset()
Definition: StdSync.h:160
bool WaitFor(int)
Definition: StdSync.h:161
virtual void Leave()
Definition: StdSync.h:151
virtual void Enter()
Definition: StdSync.h:150
long lShareCnt
Definition: StdSync.h:203
#define INFINITE
Definition: StdSync.h:58
CStdEvent ShareFreeEvent
Definition: StdSync.h:205

Here is the call graph for this function:

void CStdCSecEx::EnterShared ( )
inline

Definition at line 238 of file StdSync.h.

References CStdCSec::Enter(), and CStdCSec::Leave().

239  {
240  // lock
241  CStdCSec::Enter();
242  // add share
243  lShareCnt++;
244  // unlock
245  CStdCSec::Leave();
246  }
virtual void Leave()
Definition: StdSync.h:151
virtual void Enter()
Definition: StdSync.h:150
long lShareCnt
Definition: StdSync.h:203

Here is the call graph for this function:

void CStdCSecEx::Leave ( )
inlineoverridevirtual

Reimplemented from CStdCSec.

Definition at line 230 of file StdSync.h.

References CStdCSec::Leave(), and CStdEvent::Set().

231  {
232  // set event
234  // unlock
235  CStdCSec::Leave();
236  }
virtual void Leave()
Definition: StdSync.h:151
void Set()
Definition: StdSync.h:158
CStdEvent ShareFreeEvent
Definition: StdSync.h:205

Here is the call graph for this function:

void CStdCSecEx::LeaveShared ( )
inline

Definition at line 248 of file StdSync.h.

References CStdCSec::Enter(), CStdCSec::Leave(), and CStdEvent::Set().

Referenced by CStdShareLock::Clear().

249  {
250  // lock
251  CStdCSec::Enter();
252  // remove share
253  if (!--lShareCnt)
254  {
255  // do callback
256  if (pCallbClass)
257  pCallbClass->OnShareFree(this);
258  // set event
260  }
261  // unlock
262  CStdCSec::Leave();
263  }
virtual void OnShareFree(class CStdCSecEx *pCSec)=0
virtual void Leave()
Definition: StdSync.h:151
virtual void Enter()
Definition: StdSync.h:150
void Set()
Definition: StdSync.h:158
long lShareCnt
Definition: StdSync.h:203
CStdCSecExCallback * pCallbClass
Definition: StdSync.h:207
CStdEvent ShareFreeEvent
Definition: StdSync.h:205

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

long CStdCSecEx::lShareCnt {0}
protected

Definition at line 203 of file StdSync.h.

CStdCSecExCallback* CStdCSecEx::pCallbClass {nullptr}
protected

Definition at line 207 of file StdSync.h.

CStdEvent CStdCSecEx::ShareFreeEvent
protected

Definition at line 205 of file StdSync.h.


The documentation for this class was generated from the following file: