diff options
Diffstat (limited to 'src/vm/threads.h')
-rw-r--r-- | src/vm/threads.h | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/src/vm/threads.h b/src/vm/threads.h index ff0d1669ce..f34066feb3 100644 --- a/src/vm/threads.h +++ b/src/vm/threads.h @@ -1450,6 +1450,24 @@ public: } #endif //FEATURE_COMINTEROP +#ifndef DACCESS_COMPILE + bool HasDeadThreadBeenConsideredForGCTrigger() + { + LIMITED_METHOD_CONTRACT; + _ASSERTE(IsDead()); + + return m_fHasDeadThreadBeenConsideredForGCTrigger; + } + + void SetHasDeadThreadBeenConsideredForGCTrigger() + { + LIMITED_METHOD_CONTRACT; + _ASSERTE(IsDead()); + + m_fHasDeadThreadBeenConsideredForGCTrigger = true; + } +#endif // !DACCESS_COMPILE + // returns if there is some extra work for the finalizer thread. BOOL HaveExtraWorkForFinalizer(); @@ -3712,9 +3730,11 @@ private: void SetupForSuspension(ULONG bit) { WRAPPER_NO_CONTRACT; - if (bit & TS_UserSuspendPending) { - m_UserSuspendEvent.Reset(); - } + + // CoreCLR does not support user-requested thread suspension + _ASSERTE(!(bit & TS_UserSuspendPending)); + + if (bit & TS_DebugSuspendPending) { m_DebugSuspendEvent.Reset(); } @@ -3731,8 +3751,14 @@ private: // ThreadState oldState = m_State; + // CoreCLR does not support user-requested thread suspension + _ASSERTE(!(oldState & TS_UserSuspendPending)); + while ((oldState & (TS_UserSuspendPending | TS_DebugSuspendPending)) == 0) { + // CoreCLR does not support user-requested thread suspension + _ASSERTE(!(oldState & TS_UserSuspendPending)); + // // Construct the destination state we desire - all suspension bits turned off. // @@ -3751,9 +3777,8 @@ private: oldState = m_State; } - if (bit & TS_UserSuspendPending) { - m_UserSuspendEvent.Set(); - } + // CoreCLR does not support user-requested thread suspension + _ASSERTE(!(bit & TS_UserSuspendPending)); if (bit & TS_DebugSuspendPending) { m_DebugSuspendEvent.Set(); @@ -3761,10 +3786,6 @@ private: } - // For getting a thread to a safe point. A client waits on the event, which is - // set by the thread when it reaches a safe spot. - void SetSafeEvent(); - public: FORCEINLINE void UnhijackThreadNoAlloc() { @@ -3885,8 +3906,6 @@ public: private: // For suspends: - CLREvent m_SafeEvent; - CLREvent m_UserSuspendEvent; CLREvent m_DebugSuspendEvent; // For Object::Wait, Notify and NotifyAll, we use an Event inside the @@ -5230,6 +5249,9 @@ private: // Disables pumping and thread join in RCW creation bool m_fDisableComObjectEagerCleanup; + // See ThreadStore::TriggerGCForDeadThreadsIfNecessary() + bool m_fHasDeadThreadBeenConsideredForGCTrigger; + private: CLRRandom m_random; @@ -5516,6 +5538,8 @@ private: LONG m_PendingThreadCount; LONG m_DeadThreadCount; + LONG m_DeadThreadCountForGCTrigger; + bool m_TriggerGCForDeadThreads; private: // Space for the lazily-created GUID. @@ -5528,6 +5552,10 @@ private: Thread *m_HoldingThread; EEThreadId m_holderthreadid; // current holder (or NULL) +private: + static LONG s_DeadThreadCountThresholdForGCTrigger; + static DWORD s_DeadThreadGCTriggerPeriodMilliseconds; + public: static BOOL HoldingThreadStore() @@ -5601,6 +5629,14 @@ public: LIMITED_METHOD_CONTRACT; s_pWaitForStackCrawlEvent->Reset(); } + +private: + void IncrementDeadThreadCountForGCTrigger(); + void DecrementDeadThreadCountForGCTrigger(); +public: + void OnMaxGenerationGCStarted(); + bool ShouldTriggerGCForDeadThreads(); + void TriggerGCForDeadThreadsIfNecessary(); }; struct TSSuspendHelper { |