From b341bc090833695184276c48dd36cd946791a00c Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Thu, 13 Jan 2011 11:39:50 -0500
Subject: 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.
---
OpenSim/Framework/Util.cs | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Framework/Util.cs')
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 8d1671a..d1d8736 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -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
///
/// Created to work around a limitation in Mono with nested delegates
///
- 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 wrapper = FireAndForgetWrapper.Instance;
wrapper.FireAndForget(callback, obj);
break;
case FireAndForgetMethod.SmartThreadPool:
--
cgit v1.1