Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Mosier <smosier@microsoft.com>2015-10-14 19:59:44 +0300
committerScott Mosier <smosier@microsoft.com>2015-10-14 20:50:33 +0300
commit015b60a6ae813714a6dc576c36df4637880ab897 (patch)
tree76a3288dffb3ae226b9b2fd77747816f214f65f2 /src/Native/Runtime/Crst.h
parent9ceafad81f9c68f16c6be2e11ff609ce9f228ae9 (diff)
Additional GC-to-EE hookup.
Provide specialized gcenv.h for CoreRT. Some refactoring of related gcenv stuff. Wire up finalizer code. Add runtime-specific scanning code.
Diffstat (limited to 'src/Native/Runtime/Crst.h')
-rw-r--r--src/Native/Runtime/Crst.h80
1 files changed, 67 insertions, 13 deletions
diff --git a/src/Native/Runtime/Crst.h b/src/Native/Runtime/Crst.h
index b88066730..f1e7c100e 100644
--- a/src/Native/Runtime/Crst.h
+++ b/src/Native/Runtime/Crst.h
@@ -8,13 +8,13 @@
class EEThreadId
{
public:
- EEThreadId(UInt32 uiId) : m_uiId(uiId) {}
+ EEThreadId(uint32_t uiId) : m_uiId(uiId) {}
#ifndef DACCESS_COMPILE
- bool IsSameThread() { return PalGetCurrentThreadId() == m_uiId; }
+ bool IsSameThread();
#endif
private:
- UInt32 m_uiId;
+ uint32_t m_uiId;
};
@@ -44,7 +44,11 @@ enum CrstType
enum CrstFlags
{
- CRST_DEFAULT = 0x0,
+ CRST_DEFAULT = 0x0,
+ CRST_REENTRANCY = 0x0,
+ CRST_UNSAFE_SAMELEVEL = 0x0,
+ CRST_UNSAFE_ANYMODE = 0x0,
+ CRST_DEBUGGER_THREAD = 0x0,
};
// Static version of Crst with no default constructor (user must call Init() before use).
@@ -54,6 +58,8 @@ public:
void Init(CrstType eType, CrstFlags eFlags = CRST_DEFAULT);
bool InitNoThrow(CrstType eType, CrstFlags eFlags = CRST_DEFAULT) { Init(eType, eFlags); return true; }
void Destroy();
+ void Enter() { CrstStatic::Enter(this); }
+ void Leave() { CrstStatic::Leave(this); }
static void Enter(CrstStatic *pCrst);
static void Leave(CrstStatic *pCrst);
#if defined(_DEBUG)
@@ -64,8 +70,8 @@ public:
private:
CRITICAL_SECTION m_sCritSec;
#if defined(_DEBUG)
- UInt32 m_uiOwnerId;
- static const UInt32 UNOWNED = 0;
+ uint32_t m_uiOwnerId;
+ static const uint32_t UNOWNED = 0;
#endif // _DEBUG
};
@@ -79,14 +85,62 @@ public:
};
// Holder for a Crst instance.
-class CrstHolder : public Holder<CrstStatic*, CrstStatic::Enter, CrstStatic::Leave>
+class CrstHolder
{
+ CrstStatic * m_pLock;
+
public:
- CrstHolder(CrstStatic *pCrst, bool fTake = true) : Holder(pCrst, fTake) {}
- ~CrstHolder() {}
+ CrstHolder(CrstStatic * pLock)
+ : m_pLock(pLock)
+ {
+ m_pLock->Enter();
+ }
+
+ ~CrstHolder()
+ {
+ m_pLock->Leave();
+ }
};
-// The CLR has split the Crst holders into CrstHolder which only supports acquire on construction/release on
-// destruction semantics and CrstHolderWithState, with the old, fully flexible semantics. We don't support the
-// split yet so both types are equivalent.
-typedef CrstHolder CrstHolderWithState;
+class CrstHolderWithState
+{
+ CrstStatic * m_pLock;
+ bool m_fAcquired;
+
+public:
+ CrstHolderWithState(CrstStatic * pLock, bool fAcquire = true)
+ : m_pLock(pLock), m_fAcquired(fAcquire)
+ {
+ if (fAcquire)
+ m_pLock->Enter();
+ }
+
+ ~CrstHolderWithState()
+ {
+ if (m_fAcquired)
+ m_pLock->Leave();
+ }
+
+ void Acquire()
+ {
+ if (!m_fAcquired)
+ {
+ m_pLock->Enter();
+ m_fAcquired = true;
+ }
+ }
+
+ void Release()
+ {
+ if (m_fAcquired)
+ {
+ m_pLock->Leave();
+ m_fAcquired = false;
+ }
+ }
+
+ CrstStatic * GetValue()
+ {
+ return m_pLock;
+ }
+};