OpenClonk
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() [1/2]

CStdCSecEx::CStdCSecEx ( )
inline

Definition at line 193 of file StdSync.h.

194  : ShareFreeEvent(false)
195  { }
CStdEvent ShareFreeEvent
Definition: StdSync.h:205

◆ CStdCSecEx() [2/2]

CStdCSecEx::CStdCSecEx ( CStdCSecExCallback pCallb)
inline

Definition at line 196 of file StdSync.h.

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

◆ ~CStdCSecEx()

CStdCSecEx::~CStdCSecEx ( )
overridedefault

Member Function Documentation

◆ Enter()

void CStdCSecEx::Enter ( )
inlineoverridevirtual

Reimplemented from CStdCSec.

Definition at line 212 of file StdSync.h.

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  }
#define INFINITE
Definition: StdSync.h:58
virtual void Leave()
Definition: StdSync.h:151
virtual void Enter()
Definition: StdSync.h:150
bool WaitFor(int)
Definition: StdSync.h:161
void Reset()
Definition: StdSync.h:160

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

Here is the call graph for this function:

◆ EnterShared()

void CStdCSecEx::EnterShared ( )
inline

Definition at line 238 of file StdSync.h.

239  {
240  // lock
241  CStdCSec::Enter();
242  // add share
243  lShareCnt++;
244  // unlock
245  CStdCSec::Leave();
246  }

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

Referenced by CStdShareLock::CStdShareLock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Leave()

void CStdCSecEx::Leave ( )
inlineoverridevirtual

Reimplemented from CStdCSec.

Definition at line 230 of file StdSync.h.

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

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

Here is the call graph for this function:

◆ LeaveShared()

void CStdCSecEx::LeaveShared ( )
inline

Definition at line 248 of file StdSync.h.

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

References CStdCSec::Enter(), CStdCSec::Leave(), lShareCnt, CStdCSecExCallback::OnShareFree(), pCallbClass, CStdEvent::Set(), and ShareFreeEvent.

Referenced by CStdShareLock::Clear().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ lShareCnt

long CStdCSecEx::lShareCnt {0}
protected

Definition at line 203 of file StdSync.h.

Referenced by Enter(), EnterShared(), and LeaveShared().

◆ pCallbClass

CStdCSecExCallback* CStdCSecEx::pCallbClass {nullptr}
protected

Definition at line 207 of file StdSync.h.

Referenced by LeaveShared().

◆ ShareFreeEvent

CStdEvent CStdCSecEx::ShareFreeEvent
protected

Definition at line 205 of file StdSync.h.

Referenced by Enter(), Leave(), and LeaveShared().


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