BeCriticalSection.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
11 
12 #include "Bentley.h"
13 
14 
16 
17 /*=================================================================================**/
22  {
23 private:
24  UInt8 m_osCSect[64];
25  bool m_isValid;
26 
27 public:
28 
32  BENTLEYDLL_EXPORT ~BeCriticalSection ();
34  BENTLEYDLL_EXPORT void Enter ();
36  BENTLEYDLL_EXPORT void Leave ();
37 
39  BENTLEYDLL_EXPORT intptr_t GetOwningThreadId () const;
40 
42  BENTLEYDLL_EXPORT static intptr_t GetCurrentThreadId();
43 
45  BENTLEYDLL_EXPORT bool GetIsValid () const;
46 
47 #if defined (_WIN32) // Windows && WinRT
48  BENTLEYDLL_EXPORT bool HasEntered() const;
51 #endif
52  };
53 
54 /*=================================================================================**/
59  {
60 private:
61  BeCriticalSection& m_csect;
62 
63 public:
65  BeCriticalSectionHolder (BeCriticalSection& p) : m_csect(p) {m_csect.Enter ();}
66 
68  ~BeCriticalSectionHolder () {m_csect.Leave ();}
69  };
70 
71 
73 
BeCriticalSectionHolder(BeCriticalSection &p)
Constructs a BeCriticalSectionHolder. This enters the critical section.
Definition: BeCriticalSection.h:65
#define BENTLEYDLL_EXPORT
Definition: Bentley.h:249
A critical section/mutual exclusion object.
Definition: BeCriticalSection.h:21
A helper class that ties ownership of a BeCriticalSection object to the scope of a variable...
Definition: BeCriticalSection.h:58
uint8_t UInt8
Definition: Bentley.r.h:116
#define BEGIN_BENTLEY_NAMESPACE
Definition: Bentley.r.h:24
Defines typedefs and constants that can be used across other namespaces. All Bentley-authored C++ sou...
#define END_BENTLEY_NAMESPACE
Definition: Bentley.r.h:25
~BeCriticalSectionHolder()
Destroys the BeCriticalSectionHolder. This leaves the critical section.
Definition: BeCriticalSection.h:68

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.