ICALL_TYPE(THREADP, "System.Threading.ThreadPool", THREADP_2)
HANDLES(THREADP_2, "GetAvailableThreadsNative", ves_icall_System_Threading_ThreadPool_GetAvailableThreadsNative, void, 2, (gint32_ref, gint32_ref))
+HANDLES(THREADP_2a, "GetCompletedWorkItemCount", ves_icall_System_Threading_ThreadPool_GetCompletedWorkItemCount, gint64, 0, ())
HANDLES(THREADP_3, "GetMaxThreadsNative", ves_icall_System_Threading_ThreadPool_GetMaxThreadsNative, void, 2, (gint32_ref, gint32_ref))
HANDLES(THREADP_4, "GetMinThreadsNative", ves_icall_System_Threading_ThreadPool_GetMinThreadsNative, void, 2, (gint32_ref, gint32_ref))
+HANDLES(THREADP_4a, "GetThreadCount", ves_icall_System_Threading_ThreadPool_GetThreadCount, gint32, 0, ())
HANDLES(THREADP_5, "InitializeVMTp", ves_icall_System_Threading_ThreadPool_InitializeVMTp, void, 1, (MonoBoolean_ref))
HANDLES(THREADP_7, "NotifyWorkItemComplete", ves_icall_System_Threading_ThreadPool_NotifyWorkItemComplete, MonoBoolean, 0, ())
HANDLES(THREADP_8, "NotifyWorkItemProgressNative", ves_icall_System_Threading_ThreadPool_NotifyWorkItemProgressNative, void, 0, ())
mono_refcount_dec (&worker);
}
+#ifdef ENABLE_NETCORE
+gint64 mono_threadpool_worker_get_completed_threads_count (void)
+{
+ return worker.heuristic_completions;
+}
+
+gint32 mono_threadpool_worker_get_threads_count (void)
+{
+ ThreadPoolWorkerCounter const counter = COUNTER_READ ();
+ return counter._.working;
+}
+#endif
+
/* return TRUE if timeout, FALSE otherwise (worker unpark or interrupt) */
static gboolean
worker_park (void)
{
return FALSE;
}
+
+#ifdef ENABLE_NETCORE
+gint64 mono_threadpool_worker_get_completed_threads_count (void)
+{
+ return 0;
+}
+
+gint32 mono_threadpool_worker_get_threads_count (void)
+{
+ return 0;
+}
+#endif
gboolean
mono_threadpool_worker_notify_completed (void);
+#ifdef ENABLE_NETCORE
+gint64
+mono_threadpool_worker_get_completed_threads_count (void);
+
+gint32
+mono_threadpool_worker_get_threads_count (void);
+#endif
+
gint32
mono_threadpool_worker_get_min (void);
gboolean
return TRUE;
}
+#ifdef ENABLE_NETCORE
+gint32
+ves_icall_System_Threading_ThreadPool_GetThreadCount (MonoError *error)
+{
+ return mono_threadpool_worker_get_threads_count ();
+}
+
+gint64
+ves_icall_System_Threading_ThreadPool_GetCompletedWorkItemCount (MonoError *error)
+{
+ return mono_threadpool_worker_get_completed_threads_count ();
+}
+#endif
+
void
ves_icall_System_Threading_ThreadPool_InitializeVMTp (MonoBoolean *enable_worker_tracking, MonoError *error)
{
# Explicitly skipped if it's MonoVM (SkipOnTargetFramework)
-nomethod System.Threading.ThreadPools.Tests.ThreadPoolTests.SetMinMaxThreadsTest_ChangedInDotNetCore
-# ThreadPool.CompletedWorkItemCount is not implemented
-# https://github.com/mono/mono/issues/14829
--nomethod System.Threading.ThreadPools.Tests.ThreadPoolTests.MetricsTest
-
####################################################################
## System.ComponentModel.Composition.Tests
####################################################################
// See the LICENSE file in the project root for more information.
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
namespace System.Threading
{
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void GetAvailableThreadsNative (out int workerThreads, out int completionPortThreads);
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ static extern long GetCompletedWorkItemCount ();
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ static extern int GetThreadCount ();
+
+
public static bool SetMaxThreads (int workerThreads, int completionPortThreads)
{
return SetMaxThreadsNative (workerThreads, completionPortThreads);
static long PendingUnmanagedWorkItemCount => 0;
- public static long CompletedWorkItemCount => throw new PlatformNotSupportedException ();
+ public static long CompletedWorkItemCount => GetCompletedWorkItemCount ();
- public static int ThreadCount => throw new NotImplementedException ();
+ public static int ThreadCount => GetThreadCount ();
}
internal static class _ThreadPoolWaitCallback