Make FireAndForgetWrapper a singleton class

Made FireAndForgetWrapper a singleton class to allow us to drop
	dependancy on the BclExtras35 library. BclExtras is broken in
	Mono 2.8.2 and we used the library in only one function.
This commit is contained in:
BlueWall
2011-01-13 11:39:50 -05:00
committed by Melanie
parent 705f4e1e4b
commit 69c8cc787f
3 changed files with 24 additions and 5 deletions

View File

@@ -46,7 +46,7 @@ using System.Threading;
using log4net;
using Nini.Config;
using Nwc.XmlRpc;
using BclExtras;
// using BclExtras;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using Amib.Threading;
@@ -1375,8 +1375,29 @@ namespace OpenSim.Framework
/// <summary>
/// Created to work around a limitation in Mono with nested delegates
/// </summary>
private class FireAndForgetWrapper
private sealed class FireAndForgetWrapper
{
private static volatile FireAndForgetWrapper instance;
private static object syncRoot = new Object();
public static FireAndForgetWrapper Instance {
get {
if (instance == null)
{
lock (syncRoot)
{
if (instance == null)
{
instance = new FireAndForgetWrapper();
}
}
}
return instance;
}
}
public void FireAndForget(System.Threading.WaitCallback callback)
{
callback.BeginInvoke(null, EndFireAndForget, callback);
@@ -1445,7 +1466,7 @@ namespace OpenSim.Framework
ThreadPool.QueueUserWorkItem(callback, obj);
break;
case FireAndForgetMethod.BeginInvoke:
FireAndForgetWrapper wrapper = Singleton.GetInstance<FireAndForgetWrapper>();
FireAndForgetWrapper wrapper = FireAndForgetWrapper.Instance;
wrapper.FireAndForget(callback, obj);
break;
case FireAndForgetMethod.SmartThreadPool: