Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
CriticalSectionMutex.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
6
7 /*
8 ********************************************************************************
9 ****************************** CriticalSectionMutex ****************************
10 ********************************************************************************
11 */
12 inline CriticalSectionMutex::CriticalSectionMutex ()
13 : fCritSec_ ()
14 {
15 ::InitializeCriticalSection (&fCritSec_);
16 }
17 inline CriticalSectionMutex::~CriticalSectionMutex ()
18 {
19 ::DeleteCriticalSection (&fCritSec_);
20 }
21 inline void CriticalSectionMutex::lock ()
22 {
23 // EnterCriticalSection supports recursive mutex, but this class non-recursive.
24 // If we ever did a call where the owning thread already was this, that would deadlock forever
25 // in a non-recursive mutex, but be OK here. Assert to assure that doesn't happen.
26 Require (fCritSec_.OwningThread != ::GetCurrentThread ());
27 ::EnterCriticalSection (&fCritSec_);
28 }
29 inline void CriticalSectionMutex::unlock ()
30 {
31 ::LeaveCriticalSection (&fCritSec_);
32 }
33
34}