Simplify UuidGatherer by performing asset fetch synchronously rather than using the async call but waiting for completion anyway!
parent
1b0abf8f0c
commit
bceef401fa
|
@ -58,16 +58,16 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// </summary>
|
||||
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>
|
||||
/// Signal whether we are currently waiting for the asset service to deliver an asset.
|
||||
/// </summary>
|
||||
private bool m_waitingForObjectAsset;
|
||||
// /// <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>
|
||||
// /// Signal whether we are currently waiting for the asset service to deliver an asset.
|
||||
// /// </summary>
|
||||
// private bool m_waitingForObjectAsset;
|
||||
|
||||
public UuidGatherer(IAssetService assetCache)
|
||||
{
|
||||
|
@ -195,18 +195,18 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The callback made when we request the asset for an object from the asset service.
|
||||
/// </summary>
|
||||
private void AssetReceived(string id, Object sender, AssetBase asset)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
m_requestedObjectAsset = asset;
|
||||
m_waitingForObjectAsset = false;
|
||||
Monitor.Pulse(this);
|
||||
}
|
||||
}
|
||||
// /// <summary>
|
||||
// /// The callback made when we request the asset for an object from the asset service.
|
||||
// /// </summary>
|
||||
// private void AssetReceived(string id, Object sender, AssetBase asset)
|
||||
// {
|
||||
// lock (this)
|
||||
// {
|
||||
// m_requestedObjectAsset = asset;
|
||||
// m_waitingForObjectAsset = false;
|
||||
// Monitor.Pulse(this);
|
||||
// }
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Get an asset synchronously, potentially using an asynchronous callback. If the
|
||||
|
@ -216,25 +216,29 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <returns></returns>
|
||||
protected virtual AssetBase GetAsset(UUID uuid)
|
||||
{
|
||||
m_waitingForObjectAsset = true;
|
||||
m_assetCache.Get(uuid.ToString(), this, AssetReceived);
|
||||
return m_assetCache.Get(uuid.ToString());
|
||||
|
||||
// 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!
|
||||
// m_waitingForObjectAsset = true;
|
||||
// m_assetCache.Get(uuid.ToString(), this, AssetReceived);
|
||||
//
|
||||
// 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 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;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// The code below handles both these alternatives.
|
||||
lock (this)
|
||||
{
|
||||
if (m_waitingForObjectAsset)
|
||||
{
|
||||
Monitor.Wait(this);
|
||||
m_waitingForObjectAsset = false;
|
||||
}
|
||||
}
|
||||
|
||||
return m_requestedObjectAsset;
|
||||
// return m_requestedObjectAsset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue