[netcore] Complete Monitor.LockContentionCount implementation (mono/mono#17719)
authorAlexis Christoforides <alexis@thenull.net>
Mon, 11 Nov 2019 12:03:03 +0000 (13:03 +0100)
committerAleksey Kliger (λgeek) <alklig@microsoft.com>
Mon, 11 Nov 2019 12:03:03 +0000 (13:03 +0100)
* [netcore] Complete Monitor.LockContentionCount implementation

Fixes https://github.com/mono/mono/pull/16538

Commit migrated from https://github.com/mono/mono/commit/722c6f7dd59d235c2403c110869b74d8e63ac07d

src/mono/configure.ac
src/mono/mono/metadata/monitor.c
src/mono/netcore/CoreFX.issues.rsp

index 30949f3..387bb1f 100644 (file)
@@ -63,7 +63,7 @@ MONO_VERSION_BUILD=`echo $VERSION | cut -d . -f 3`
 # This line is parsed by tools besides autoconf, such as msvc/mono.winconfig.targets.
 # It should remain in the format they expect.
 #
-MONO_CORLIB_VERSION=4e2d4257-1f2b-418c-9829-dd006fe09df5
+MONO_CORLIB_VERSION=3EAB4D03-8026-4D77-B1AE-AC96DF737E67
 
 #
 # Put a quoted #define in config.h.
index d488dbc..58865e7 100644 (file)
@@ -791,6 +791,10 @@ signal_monitor (gpointer mon_untyped)
        mono_coop_mutex_unlock (mon->entry_mutex);
 }
 
+#ifdef ENABLE_NETCORE
+static gint64 thread_contentions; /* for Monitor.LockContentionCount, otherwise mono_perfcounters struct is used */
+#endif
+
 /* If allow_interruption==TRUE, the method will be interrupted if abort or suspend
  * is requested. In this case it returns -1.
  */ 
@@ -847,6 +851,10 @@ retry:
        /* The object must be locked by someone else... */
 #ifndef DISABLE_PERFCOUNTERS
        mono_atomic_inc_i32 (&mono_perfcounters->thread_contentions);
+#else
+#ifdef ENABLE_NETCORE
+       mono_atomic_inc_i64 (&thread_contentions);
+#endif
 #endif
 
        /* If ms is 0 we don't block, but just fail straight away */
@@ -1511,7 +1519,7 @@ ves_icall_System_Threading_Monitor_Monitor_LockContentionCount (void)
 #ifndef DISABLE_PERFCOUNTERS
        return mono_perfcounters->thread_contentions;
 #else
-       return 0;
+       return thread_contentions;
 #endif
 }
-#endif
\ No newline at end of file
+#endif
index 090e5d9..ef3845d 100644 (file)
 ##  System.Threading.Tests
 ####################################################################
 
-# Monitor.LockContentionCount is not implemented
-# Implementation https://github.com/mono/mono/issues/15155
-# https://github.com/mono/mono/issues/15156
--nomethod System.Threading.Tests.MonitorTests.Enter_HasToWait_LockContentionCountTest
-
 # Process hangs and test fails with [ERROR] FATAL UNHANDLED EXCEPTION: System.Threading.WaitHandleCannotBeOpenedException: No handle of the given name exists.
 # https://github.com/mono/mono/issues/15157
 -nomethod System.Threading.Tests.MutexTests.CrossProcess_NamedMutex_ProtectedFileAccessAtomic