* Change simple asset cache test to manually pump the asset server rather than relying on another thread
parent
2a49272b62
commit
e1c449b492
|
@ -139,13 +139,28 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
/// </exception>
|
||||
protected abstract AssetBase GetAsset(AssetRequest req);
|
||||
|
||||
/// <summary>
|
||||
/// Does the asset server have any waiting requests?
|
||||
/// </summary>
|
||||
///
|
||||
/// This does include any request that is currently being handled. This information is not reliable where
|
||||
/// another thread may be processing requests.
|
||||
///
|
||||
/// <returns>
|
||||
/// True if there are waiting requests. False if there are no waiting requests.
|
||||
/// </returns>
|
||||
public virtual bool HasWaitingRequests()
|
||||
{
|
||||
return m_assetRequests.Count() != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process an asset request. This method will call GetAsset(AssetRequest req)
|
||||
/// on the subclass.
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
protected virtual void ProcessRequest(AssetRequest req)
|
||||
public virtual void ProcessNextRequest()
|
||||
{
|
||||
AssetRequest req = m_assetRequests.Dequeue();
|
||||
AssetBase asset;
|
||||
|
||||
try
|
||||
|
@ -191,9 +206,7 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
{
|
||||
try
|
||||
{
|
||||
AssetRequest req = m_assetRequests.Dequeue();
|
||||
|
||||
ProcessRequest(req);
|
||||
ProcessNextRequest();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -62,15 +62,14 @@ namespace OpenSim.Framework.Communications.Tests
|
|||
TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin();
|
||||
assetPlugin.CreateAsset(asset);
|
||||
|
||||
IAssetServer assetServer = new SQLAssetServer(assetPlugin);
|
||||
SQLAssetServer assetServer = new SQLAssetServer(assetPlugin);
|
||||
IAssetCache assetCache = new AssetCache(assetServer);
|
||||
assetServer.Start();
|
||||
|
||||
lock (this)
|
||||
{
|
||||
assetCache.GetAsset(assetId, AssetRequestCallback, false);
|
||||
Monitor.Wait(this, 60000);
|
||||
}
|
||||
|
||||
// Manually pump the asset server
|
||||
while (assetServer.HasWaitingRequests())
|
||||
assetServer.ProcessNextRequest();
|
||||
|
||||
Assert.That(
|
||||
assetId, Is.EqualTo(m_assetIdReceived), "Asset id stored differs from asset id received");
|
||||
|
|
Loading…
Reference in New Issue