diff options
author | BlueWall | 2011-01-13 11:39:50 -0500 |
---|---|---|
committer | BlueWall | 2011-01-13 11:39:50 -0500 |
commit | b341bc090833695184276c48dd36cd946791a00c (patch) | |
tree | 8ad79e288e7fd603511a8ea0159f517d5faf8f2a /OpenSim | |
parent | Dont' trust the viewer! Fix a permission slam error caused by trusting (diff) | |
download | opensim-SC-b341bc090833695184276c48dd36cd946791a00c.zip opensim-SC-b341bc090833695184276c48dd36cd946791a00c.tar.gz opensim-SC-b341bc090833695184276c48dd36cd946791a00c.tar.bz2 opensim-SC-b341bc090833695184276c48dd36cd946791a00c.tar.xz |
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.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Util.cs | 27 |
1 files changed, 24 insertions, 3 deletions
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; | |||
46 | using log4net; | 46 | using log4net; |
47 | using Nini.Config; | 47 | using Nini.Config; |
48 | using Nwc.XmlRpc; | 48 | using Nwc.XmlRpc; |
49 | using BclExtras; | 49 | // using BclExtras; |
50 | using OpenMetaverse; | 50 | using OpenMetaverse; |
51 | using OpenMetaverse.StructuredData; | 51 | using OpenMetaverse.StructuredData; |
52 | using Amib.Threading; | 52 | using Amib.Threading; |
@@ -1375,8 +1375,29 @@ namespace OpenSim.Framework | |||
1375 | /// <summary> | 1375 | /// <summary> |
1376 | /// Created to work around a limitation in Mono with nested delegates | 1376 | /// Created to work around a limitation in Mono with nested delegates |
1377 | /// </summary> | 1377 | /// </summary> |
1378 | private class FireAndForgetWrapper | 1378 | private sealed class FireAndForgetWrapper |
1379 | { | 1379 | { |
1380 | private static volatile FireAndForgetWrapper instance; | ||
1381 | private static object syncRoot = new Object(); | ||
1382 | |||
1383 | public static FireAndForgetWrapper Instance { | ||
1384 | get { | ||
1385 | |||
1386 | if (instance == null) | ||
1387 | { | ||
1388 | lock (syncRoot) | ||
1389 | { | ||
1390 | if (instance == null) | ||
1391 | { | ||
1392 | instance = new FireAndForgetWrapper(); | ||
1393 | } | ||
1394 | } | ||
1395 | } | ||
1396 | |||
1397 | return instance; | ||
1398 | } | ||
1399 | } | ||
1400 | |||
1380 | public void FireAndForget(System.Threading.WaitCallback callback) | 1401 | public void FireAndForget(System.Threading.WaitCallback callback) |
1381 | { | 1402 | { |
1382 | callback.BeginInvoke(null, EndFireAndForget, callback); | 1403 | callback.BeginInvoke(null, EndFireAndForget, callback); |
@@ -1445,7 +1466,7 @@ namespace OpenSim.Framework | |||
1445 | ThreadPool.QueueUserWorkItem(callback, obj); | 1466 | ThreadPool.QueueUserWorkItem(callback, obj); |
1446 | break; | 1467 | break; |
1447 | case FireAndForgetMethod.BeginInvoke: | 1468 | case FireAndForgetMethod.BeginInvoke: |
1448 | FireAndForgetWrapper wrapper = Singleton.GetInstance<FireAndForgetWrapper>(); | 1469 | FireAndForgetWrapper wrapper = FireAndForgetWrapper.Instance; |
1449 | wrapper.FireAndForget(callback, obj); | 1470 | wrapper.FireAndForget(callback, obj); |
1450 | break; | 1471 | break; |
1451 | case FireAndForgetMethod.SmartThreadPool: | 1472 | case FireAndForgetMethod.SmartThreadPool: |