logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpsen...@apache.org
Subject svn commit: r1490222 - /logging/log4net/trunk/src/Util/ReaderWriterLock.cs
Date Thu, 06 Jun 2013 10:11:11 GMT
Author: dpsenner
Date: Thu Jun  6 10:11:11 2013
New Revision: 1490222

URL: http://svn.apache.org/r1490222
Log:
LOG4NET-232 pulled in a modified version of Cosmin Onea's patch that allows log4net to use
the ReaderWriterLockSlim in newer .NET versions

Modified:
    logging/log4net/trunk/src/Util/ReaderWriterLock.cs

Modified: logging/log4net/trunk/src/Util/ReaderWriterLock.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Util/ReaderWriterLock.cs?rev=1490222&r1=1490221&r2=1490222&view=diff
==============================================================================
--- logging/log4net/trunk/src/Util/ReaderWriterLock.cs (original)
+++ logging/log4net/trunk/src/Util/ReaderWriterLock.cs Thu Jun  6 10:11:11 2013
@@ -20,6 +20,9 @@
 #if (!NETCF)
 #define HAS_READERWRITERLOCK
 #endif
+#if (NET_4_0)
+#define HAS_READERWRITERLOCKSLIM
+#endif
 
 using System;
 
@@ -58,9 +61,14 @@ namespace log4net.Util
 		/// </remarks>
 		public ReaderWriterLock()
 		{
+
 #if HAS_READERWRITERLOCK
+#if HAS_READERWRITERLOCKSLIM
+			m_lock = new System.Threading.ReaderWriterLockSlim();
+#else
 			m_lock = new System.Threading.ReaderWriterLock();
 #endif
+#endif
 		}
 
 		#endregion Private Instance Constructors
@@ -79,7 +87,11 @@ namespace log4net.Util
 		public void AcquireReaderLock()
 		{
 #if HAS_READERWRITERLOCK
+#if HAS_READERWRITERLOCKSLIM
+			m_lock.EnterReadLock();
+#else
 			m_lock.AcquireReaderLock(-1);
+#endif
 #else
 			System.Threading.Monitor.Enter(this);
 #endif
@@ -97,7 +109,12 @@ namespace log4net.Util
 		public void ReleaseReaderLock()
 		{
 #if HAS_READERWRITERLOCK
+#if HAS_READERWRITERLOCKSLIM
+			m_lock.ExitReadLock();
+#else
 			m_lock.ReleaseReaderLock();
+
+#endif
 #else
 			System.Threading.Monitor.Exit(this);
 #endif
@@ -114,7 +131,11 @@ namespace log4net.Util
 		public void AcquireWriterLock()
 		{
 #if HAS_READERWRITERLOCK
+#if HAS_READERWRITERLOCKSLIM
+			m_lock.EnterWriteLock();
+#else
 			m_lock.AcquireWriterLock(-1);
+#endif
 #else
 			System.Threading.Monitor.Enter(this);
 #endif
@@ -132,7 +153,11 @@ namespace log4net.Util
 		public void ReleaseWriterLock()
 		{
 #if HAS_READERWRITERLOCK
+#if HAS_READERWRITERLOCKSLIM
+			m_lock.ExitWriteLock();
+#else
 			m_lock.ReleaseWriterLock();
+#endif
 #else
 			System.Threading.Monitor.Exit(this);
 #endif
@@ -143,9 +168,14 @@ namespace log4net.Util
 		#region Private Members
 
 #if HAS_READERWRITERLOCK
+#if HAS_READERWRITERLOCKSLIM
+		private System.Threading.ReaderWriterLockSlim m_lock;
+#else
 		private System.Threading.ReaderWriterLock m_lock;
 #endif
 
+#endif
+
 		#endregion
 	}
-}
+}
\ No newline at end of file



Mime
View raw message