summaryrefslogtreecommitdiff
path: root/src/vm/profdetach.h
diff options
context:
space:
mode:
authordotnet-bot <dotnet-bot@microsoft.com>2015-01-30 14:14:42 -0800
committerdotnet-bot <dotnet-bot@microsoft.com>2015-01-30 14:14:42 -0800
commitef1e2ab328087c61a6878c1e84f4fc5d710aebce (patch)
treedee1bbb89e9d722e16b0d1485e3cdd1b6c8e2cfa /src/vm/profdetach.h
downloadcoreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.gz
coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.bz2
coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.zip
Initial commit to populate CoreCLR repo
[tfs-changeset: 1407945]
Diffstat (limited to 'src/vm/profdetach.h')
-rw-r--r--src/vm/profdetach.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/vm/profdetach.h b/src/vm/profdetach.h
new file mode 100644
index 0000000000..5c3f55c29f
--- /dev/null
+++ b/src/vm/profdetach.h
@@ -0,0 +1,79 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+//
+// ProfDetach.h
+//
+
+//
+// Declaration of helper classes and structures used for Profiling API Detaching
+//
+// ======================================================================================
+
+#ifndef __PROFDETACH_H__
+#define __PROFDETACH_H__
+
+#ifdef FEATURE_PROFAPI_ATTACH_DETACH
+
+// The struct below is the medium by which RequestProfilerDetach communicates with
+// the DetachThread about a profiler being detached. Initial core attach /
+// detach feature crew will have only one global instance of this struct.
+// When we allow re-attach with neutered profilers, there will likely be a
+// linked list of these, one per profiler in the act of being detached.
+struct ProfilerDetachInfo
+{
+ ProfilerDetachInfo();
+ void Init();
+
+ // NULL if we're not trying to detach a profiler. Otherwise, this is the
+ // EEToProfInterfaceImpl instance we're detaching.
+ //
+ // FUTURE: Although m_pEEToProf, when non-NULL, is always the same as
+ // g_profControlBlock.pProfInterface, that will no longer be the case once we allow
+ // re-attach with neutered profilers.
+ EEToProfInterfaceImpl * m_pEEToProf;
+
+ // Time when profiler originally called RequestProfilerDetach()
+ ULONGLONG m_ui64DetachStartTime;
+
+ // # milliseconds hint profiler specified in RequestProfilerDetach()
+ DWORD m_dwExpectedCompletionMilliseconds;
+};
+
+//--------------------------------------------------------------------------
+// Static-only class to coordinate initialization of the various profiling
+// API detaching structures, plus other utility stuff.
+//
+class ProfilingAPIDetach
+{
+public:
+ static HRESULT Initialize();
+
+ static HRESULT RequestProfilerDetach(DWORD dwExpectedCompletionMilliseconds);
+
+ static HRESULT CreateDetachThread();
+ static DWORD WINAPI ProfilingAPIDetachThreadStart(LPVOID lpParameter);
+ static void ExecuteEvacuationLoop();
+ static BOOL IsProfilerEvacuated();
+
+ static EEToProfInterfaceImpl * GetEEToProfPtr();
+
+private:
+ static ProfilerDetachInfo s_profilerDetachInfo;
+
+ // Signaled by RequestProfilerDetach() when there is detach work ready to be
+ // done by the DetachThread
+ static CLREvent s_eventDetachWorkAvailable;
+
+ static void SleepWhileProfilerEvacuates();
+ static void UnloadProfiler();
+
+ // Prevent instantiation of ProfilingAPIDetach objects (should be static-only)
+ ProfilingAPIDetach();
+ ~ProfilingAPIDetach();
+};
+
+#endif // FEATURE_PROFAPI_ATTACH_DETACH
+
+#endif //__PROFDETACH_H__