Simplify UuidGatherer by performing asset fetch synchronously rather than using the async call but waiting for completion anyway!
parent
d31a951d94
commit
8068c083f6
|
@ -57,17 +57,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// Asset cache used for gathering assets
|
/// Asset cache used for gathering assets
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected IAssetService m_assetCache;
|
protected IAssetService m_assetCache;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 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.
|
|
||||||
/// </summary>
|
|
||||||
private AssetBase m_requestedObjectAsset;
|
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// Signal whether we are currently waiting for the asset service to deliver an asset.
|
// /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
|
||||||
/// </summary>
|
// /// asset was found by the asset service.
|
||||||
private bool m_waitingForObjectAsset;
|
// /// </summary>
|
||||||
|
// private AssetBase m_requestedObjectAsset;
|
||||||
|
//
|
||||||
|
// /// <summary>
|
||||||
|
// /// Signal whether we are currently waiting for the asset service to deliver an asset.
|
||||||
|
// /// </summary>
|
||||||
|
// private bool m_waitingForObjectAsset;
|
||||||
|
|
||||||
public UuidGatherer(IAssetService assetCache)
|
public UuidGatherer(IAssetService assetCache)
|
||||||
{
|
{
|
||||||
|
@ -195,18 +195,18 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// The callback made when we request the asset for an object from the asset service.
|
// /// The callback made when we request the asset for an object from the asset service.
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
private void AssetReceived(string id, Object sender, AssetBase asset)
|
// private void AssetReceived(string id, Object sender, AssetBase asset)
|
||||||
{
|
// {
|
||||||
lock (this)
|
// lock (this)
|
||||||
{
|
// {
|
||||||
m_requestedObjectAsset = asset;
|
// m_requestedObjectAsset = asset;
|
||||||
m_waitingForObjectAsset = false;
|
// m_waitingForObjectAsset = false;
|
||||||
Monitor.Pulse(this);
|
// Monitor.Pulse(this);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get an asset synchronously, potentially using an asynchronous callback. If the
|
/// Get an asset synchronously, potentially using an asynchronous callback. If the
|
||||||
|
@ -216,25 +216,29 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected virtual AssetBase GetAsset(UUID uuid)
|
protected virtual AssetBase GetAsset(UUID uuid)
|
||||||
{
|
{
|
||||||
m_waitingForObjectAsset = true;
|
return m_assetCache.Get(uuid.ToString());
|
||||||
m_assetCache.Get(uuid.ToString(), this, AssetReceived);
|
|
||||||
|
|
||||||
// The asset cache callback can either
|
// XXX: Switching to do this synchronously where the call was async before but we always waited for it
|
||||||
//
|
// to complete anyway!
|
||||||
// 1. Complete on the same thread (if the asset is already in the cache) or
|
// m_waitingForObjectAsset = true;
|
||||||
// 2. Come in via a different thread (if we need to go fetch it).
|
// m_assetCache.Get(uuid.ToString(), this, AssetReceived);
|
||||||
//
|
//
|
||||||
// The code below handles both these alternatives.
|
// // The asset cache callback can either
|
||||||
lock (this)
|
// //
|
||||||
{
|
// // 1. Complete on the same thread (if the asset is already in the cache) or
|
||||||
if (m_waitingForObjectAsset)
|
// // 2. Come in via a different thread (if we need to go fetch it).
|
||||||
{
|
// //
|
||||||
Monitor.Wait(this);
|
// // The code below handles both these alternatives.
|
||||||
m_waitingForObjectAsset = false;
|
// lock (this)
|
||||||
}
|
// {
|
||||||
}
|
// if (m_waitingForObjectAsset)
|
||||||
|
// {
|
||||||
return m_requestedObjectAsset;
|
// Monitor.Wait(this);
|
||||||
|
// m_waitingForObjectAsset = false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return m_requestedObjectAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue