diff options
author | Koundinya Veluri <kouvel@users.noreply.github.com> | 2019-04-19 19:22:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-19 19:22:53 -0700 |
commit | 0410c3e4fe54590eea34aead28f550539d814b98 (patch) | |
tree | 0a7d9b8ee2df4e672024ed410ee04e267f8e5bbe /src/System.Private.CoreLib/src/System/Threading | |
parent | 924d4fcc6961a76881a42a5a4a80479352708ace (diff) | |
download | coreclr-0410c3e4fe54590eea34aead28f550539d814b98.tar.gz coreclr-0410c3e4fe54590eea34aead28f550539d814b98.tar.bz2 coreclr-0410c3e4fe54590eea34aead28f550539d814b98.zip |
Implement APIs for some threading metrics (CoreCLR) (#24113)
Implement APIs for some threading metrics (CoreCLR)
API review: https://github.com/dotnet/corefx/issues/35500
Diffstat (limited to 'src/System.Private.CoreLib/src/System/Threading')
-rw-r--r-- | src/System.Private.CoreLib/src/System/Threading/Monitor.cs | 9 | ||||
-rw-r--r-- | src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs | 30 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/src/System/Threading/Monitor.cs b/src/System.Private.CoreLib/src/System/Threading/Monitor.cs index 2701b3b555..cb3a0f61d5 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Monitor.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Monitor.cs @@ -233,5 +233,14 @@ namespace System.Threading ObjPulseAll(obj); } + + /// <summary> + /// Gets the number of times there was contention upon trying to take a <see cref="Monitor"/>'s lock so far. + /// </summary> + public static extern long LockContentionCount + { + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } } } diff --git a/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs index 89030787ed..76eb2db0ad 100644 --- a/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs @@ -231,6 +231,36 @@ namespace System.Threading GetAvailableThreadsNative(out workerThreads, out completionPortThreads); } + /// <summary> + /// Gets the number of thread pool threads that currently exist. + /// </summary> + /// <remarks> + /// For a thread pool implementation that may have different types of threads, the count includes all types. + /// </remarks> + public static extern int ThreadCount + { + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + + /// <summary> + /// Gets the number of work items that have been processed so far. + /// </summary> + /// <remarks> + /// For a thread pool implementation that may have different types of work items, the count includes all types. + /// </remarks> + public static extern long CompletedWorkItemCount + { + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + + private static extern long PendingUnmanagedWorkItemCount + { + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + private static RegisteredWaitHandle RegisterWaitForSingleObject( // throws RegisterWaitException WaitHandle waitObject, WaitOrTimerCallback callBack, |