[Mono-devel-list] [PATCH] Reworked unified Locale classes

Jörg Rosenkranz joergr at voelcker.com
Thu Jun 23 09:03:46 EDT 2005


Hi all,

> -----Original Message-----
> From: mono-devel-list-bounces at lists.ximian.com 
> [mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf 
> Of Jonathan Pryor
> 
> There are four solutions:
> 
> 	- Make `resources' `volatile', which disables any caching the 
> 	  processor might do.  This effectively makes reads & writes
> 	  a memory barrier operation, slowing things down
> 
> 	- Always acquire a lock before reading `resources' -- also 
> 	  slow, due to the locking required.
> 
> 	- If it's safe to create multiple instances of 
> 	  GetTextResourceManager, you could use an 
> 	  Interlocked.CompareExchange to set `resource' for lock-free
> 	  thread-safe code.  See:
> 
> 	  
> http://mono.myrealbox.com/source/trunk/mcs/class/System/System
> .Diagnostics/TraceImpl.cs
> 
> 	  And search for `#if !NO_LOCK_FREE' for an example.
> 
> 	- Place `resource' into a different class and use a static 
> 	  constructor.  GetResourceManager can then catch for the 
> 	  TypeInitializationException and provide fallback behavior.


How about using Thread.MemoryBarrier how it's been suggested
in Brad Abrams' blog: http://blogs.msdn.com/brada/archive/2004/05/12/130935.aspx
Is this supposed to work on Mono?

Joerg. 



More information about the Mono-devel-list mailing list