From e9153e1d1aae50024d8cd05fe14a9bce34343a0e Mon Sep 17 00:00:00 2001
From: teravus
Date: Thu, 15 Nov 2012 10:05:16 -0500
Subject: Revert "Merge master into teravuswork", it should have been
avination, not master.
This reverts commit dfac269032300872c4d0dc507f4f9062d102b0f4, reversing
changes made to 619c39e5144f15aca129d6d999bcc5c34133ee64.
---
OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 138 ++++++++----------------
1 file changed, 47 insertions(+), 91 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/UuidGatherer.cs')
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 2279e62..411e421 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -52,23 +52,26 @@ namespace OpenSim.Region.Framework.Scenes
public class UuidGatherer
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ ///
+ /// Asset cache used for gathering assets
+ ///
+ protected IAssetService m_assetCache;
+
+ ///
+ /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
+ /// asset was found by the asset service.
+ ///
+ private AssetBase m_requestedObjectAsset;
- protected IAssetService m_assetService;
-
-// ///
-// /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
-// /// asset was found by the asset service.
-// ///
-// private AssetBase m_requestedObjectAsset;
-//
-// ///
-// /// Signal whether we are currently waiting for the asset service to deliver an asset.
-// ///
-// private bool m_waitingForObjectAsset;
+ ///
+ /// Signal whether we are currently waiting for the asset service to deliver an asset.
+ ///
+ private bool m_waitingForObjectAsset;
- public UuidGatherer(IAssetService assetService)
+ public UuidGatherer(IAssetService assetCache)
{
- m_assetService = assetService;
+ m_assetCache = assetCache;
}
///
@@ -188,18 +191,18 @@ namespace OpenSim.Region.Framework.Scenes
}
}
-// ///
-// /// The callback made when we request the asset for an object from the asset service.
-// ///
-// private void AssetReceived(string id, Object sender, AssetBase asset)
-// {
-// lock (this)
-// {
-// m_requestedObjectAsset = asset;
-// m_waitingForObjectAsset = false;
-// Monitor.Pulse(this);
-// }
-// }
+ ///
+ /// The callback made when we request the asset for an object from the asset service.
+ ///
+ private void AssetReceived(string id, Object sender, AssetBase asset)
+ {
+ lock (this)
+ {
+ m_requestedObjectAsset = asset;
+ m_waitingForObjectAsset = false;
+ Monitor.Pulse(this);
+ }
+ }
///
/// Get an asset synchronously, potentially using an asynchronous callback. If the
@@ -209,29 +212,25 @@ namespace OpenSim.Region.Framework.Scenes
///
protected virtual AssetBase GetAsset(UUID uuid)
{
- return m_assetService.Get(uuid.ToString());
+ m_waitingForObjectAsset = true;
+ m_assetCache.Get(uuid.ToString(), this, AssetReceived);
+
+ // The asset cache callback can either
+ //
+ // 1. Complete on the same thread (if the asset is already in the cache) or
+ // 2. Come in via a different thread (if we need to go fetch it).
+ //
+ // The code below handles both these alternatives.
+ lock (this)
+ {
+ if (m_waitingForObjectAsset)
+ {
+ Monitor.Wait(this);
+ m_waitingForObjectAsset = false;
+ }
+ }
- // XXX: Switching to do this synchronously where the call was async before but we always waited for it
- // to complete anyway!
-// m_waitingForObjectAsset = true;
-// m_assetCache.Get(uuid.ToString(), this, AssetReceived);
-//
-// // The asset cache callback can either
-// //
-// // 1. Complete on the same thread (if the asset is already in the cache) or
-// // 2. Come in via a different thread (if we need to go fetch it).
-// //
-// // The code below handles both these alternatives.
-// lock (this)
-// {
-// if (m_waitingForObjectAsset)
-// {
-// Monitor.Wait(this);
-// m_waitingForObjectAsset = false;
-// }
-// }
-//
-// return m_requestedObjectAsset;
+ return m_requestedObjectAsset;
}
///
@@ -362,47 +361,4 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
-
- public class HGUuidGatherer : UuidGatherer
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- protected string m_assetServerURL;
-
- public HGUuidGatherer(IAssetService assetService, string assetServerURL)
- : base(assetService)
- {
- m_assetServerURL = assetServerURL;
- if (!m_assetServerURL.EndsWith("/") && !m_assetServerURL.EndsWith("="))
- m_assetServerURL = m_assetServerURL + "/";
- }
-
- protected override AssetBase GetAsset(UUID uuid)
- {
- if (string.Empty == m_assetServerURL)
- return base.GetAsset(uuid);
- else
- return FetchAsset(uuid);
- }
-
- public AssetBase FetchAsset(UUID assetID)
- {
-
- // Test if it's already here
- AssetBase asset = m_assetService.Get(assetID.ToString());
- if (asset == null)
- {
- // It's not, so fetch it from abroad
- asset = m_assetService.Get(m_assetServerURL + assetID.ToString());
- if (asset != null)
- m_log.DebugFormat("[HGUUIDGatherer]: Copied asset {0} from {1} to local asset server", assetID, m_assetServerURL);
- else
- m_log.DebugFormat("[HGUUIDGatherer]: Failed to fetch asset {0} from {1}", assetID, m_assetServerURL);
- }
- //else
- // m_log.DebugFormat("[HGUUIDGatherer]: Asset {0} from {1} was already here", assetID, m_assetServerURL);
-
- return asset;
- }
- }
}
--
cgit v1.1