This latches the m_isGarbageCollectionEventsEnabled in BeforeGarbageCollection
to ensure that if we send a BeforeGC event we will send the corresponding
AfterGC event. It also ensure we will not send an AfterGC event if we did not
send the corresponding BeforeGC event.
m_pLazyData(NULL),
m_defines(_defines),
m_isBlockedOnGarbageCollectionEvent(FALSE),
- m_isGarbageCollectionEventsEnabled(FALSE)
+ m_isGarbageCollectionEventsEnabled(FALSE),
+ m_isGarbageCollectionEventsEnabledLatch(FALSE)
{
CONTRACTL
{
}
CONTRACTL_END;
- if (!CORDebuggerAttached() || !this->m_isGarbageCollectionEventsEnabled)
+ this->m_isGarbageCollectionEventsEnabledLatch = this->m_isGarbageCollectionEventsEnabled;
+
+ if (!CORDebuggerAttached() || !this->m_isGarbageCollectionEventsEnabledLatch)
{
return;
}
}
CONTRACTL_END;
- if (!CORDebuggerAttached() || !this->m_isGarbageCollectionEventsEnabled)
+ if (!CORDebuggerAttached() || !this->m_isGarbageCollectionEventsEnabledLatch)
{
return;
}
#endif
BOOL m_isBlockedOnGarbageCollectionEvent;
BOOL m_isGarbageCollectionEventsEnabled;
+ // this latches m_isGarbageCollectionEventsEnabled in BeforeGarbageCollection so we can
+ // guarantee the corresponding AfterGC event is sent even if the events are disabled during GC.
+ BOOL m_isGarbageCollectionEventsEnabledLatch;
private:
HANDLE GetGarbageCollectionBlockerEvent() { return GetLazyData()->m_garbageCollectionBlockerEvent; }