diff options
author | Jonathan Pryor <jpryor@novell.com> | 2005-01-18 18:52:48 +0300 |
---|---|---|
committer | Jonathan Pryor <jpryor@novell.com> | 2005-01-18 18:52:48 +0300 |
commit | 976e1157c7e1228681f329a371434b4fa58e7926 (patch) | |
tree | 85f69a0e4d43c6e2f7371e9b66406bdd83c14f8d /mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs | |
parent | a1e6e64402d61ffc9ff3f4851220b9224192f1ff (diff) |
* DiagnosticsConfigurationHandler.cs (DiagnosticsConfiguration):
Use a lock-free algorithm for creating the settings information.
* TraceImpl.cs (InitOnce): Use a lock-free algorithm for creating the
listeners collection and initializing the world.
svn path=/trunk/mcs/; revision=39098
Diffstat (limited to 'mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs')
-rw-r--r-- | mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs b/mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs index 54334aac9d8..28ecc78013a 100644 --- a/mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs +++ b/mcs/class/System/System.Diagnostics/DiagnosticsConfigurationHandler.cs @@ -34,6 +34,7 @@ using System; using System.Collections; using System.Configuration; +using System.Threading; #if (XML_DEP) using System.Xml; #endif @@ -41,16 +42,29 @@ namespace System.Diagnostics { internal sealed class DiagnosticsConfiguration { +#if NO_LOCK_FREE private static object lock_ = new object(); - private static IDictionary settings; +#endif + private static object settings; public static IDictionary Settings { get { +#if !NO_LOCK_FREE + if (settings == null) { + object s = ConfigurationSettings.GetConfig ("system.diagnostics"); + Thread.MemoryBarrier (); + while (Interlocked.CompareExchange (ref settings, s, null) == null) { + // do nothing; we're just setting settings. + } + Thread.MemoryBarrier (); + } +#else lock (lock_) { if (settings == null) - settings = (IDictionary) ConfigurationSettings.GetConfig ("system.diagnostics"); + settings = ConfigurationSettings.GetConfig ("system.diagnostics"); } - return settings; +#endif + return (IDictionary) settings; } } } |