Add new FireAndForgetMethod.None.
This executes the callback on the same thread that made the request. Designed for use only by regression tests that rely on a predicable event ordering.bulletsim
parent
d3c10e609e
commit
57e54d84d6
|
@ -412,12 +412,20 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add an attachment, if the attachpoint has the
|
/// Add an attachment
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If the attachpoint has the
|
||||||
/// 0x80 bit set then we assume this is an append
|
/// 0x80 bit set then we assume this is an append
|
||||||
/// operation otherwise we replace whatever is
|
/// operation otherwise we replace whatever is
|
||||||
/// currently attached at the attachpoint
|
/// currently attached at the attachpoint
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="attachpoint"></param>
|
||||||
|
/// <param name="item">If UUID.Zero, then an any attachment at the attachpoint is removed.</param>
|
||||||
|
/// <param name="asset"></param>
|
||||||
|
/// <returns>
|
||||||
/// return true if something actually changed
|
/// return true if something actually changed
|
||||||
/// </summary>
|
/// </returns>
|
||||||
public bool SetAttachment(int attachpoint, UUID item, UUID asset)
|
public bool SetAttachment(int attachpoint, UUID item, UUID asset)
|
||||||
{
|
{
|
||||||
if (attachpoint == 0)
|
if (attachpoint == 0)
|
||||||
|
|
|
@ -56,8 +56,13 @@ namespace OpenSim.Framework
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The method used by Util.FireAndForget for asynchronously firing events
|
/// The method used by Util.FireAndForget for asynchronously firing events
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// None is used to execute the method in the same thread that made the call. It should only be used by regression
|
||||||
|
/// test code that relies on predictable event ordering.
|
||||||
|
/// </remarks>
|
||||||
public enum FireAndForgetMethod
|
public enum FireAndForgetMethod
|
||||||
{
|
{
|
||||||
|
None,
|
||||||
UnsafeQueueUserWorkItem,
|
UnsafeQueueUserWorkItem,
|
||||||
QueueUserWorkItem,
|
QueueUserWorkItem,
|
||||||
BeginInvoke,
|
BeginInvoke,
|
||||||
|
@ -89,7 +94,8 @@ namespace OpenSim.Framework
|
||||||
public static readonly Regex UUIDPattern
|
public static readonly Regex UUIDPattern
|
||||||
= new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
|
= new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
|
||||||
|
|
||||||
public static FireAndForgetMethod FireAndForgetMethod = FireAndForgetMethod.SmartThreadPool;
|
public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool;
|
||||||
|
public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the directory where the current running executable
|
/// Gets the name of the directory where the current running executable
|
||||||
|
@ -1506,6 +1512,9 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
switch (FireAndForgetMethod)
|
switch (FireAndForgetMethod)
|
||||||
{
|
{
|
||||||
|
case FireAndForgetMethod.None:
|
||||||
|
realCallback.Invoke(obj);
|
||||||
|
break;
|
||||||
case FireAndForgetMethod.UnsafeQueueUserWorkItem:
|
case FireAndForgetMethod.UnsafeQueueUserWorkItem:
|
||||||
ThreadPool.UnsafeQueueUserWorkItem(realCallback, obj);
|
ThreadPool.UnsafeQueueUserWorkItem(realCallback, obj);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -37,10 +37,11 @@ using NUnit.Framework;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications;
|
using OpenSim.Framework.Communications;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.CoreModules.Avatar.Attachments;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
|
||||||
using OpenSim.Region.CoreModules.World.Serialiser;
|
using OpenSim.Region.CoreModules.World.Serialiser;
|
||||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
|
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
|
||||||
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Tests.Common;
|
using OpenSim.Tests.Common;
|
||||||
using OpenSim.Tests.Common.Mock;
|
using OpenSim.Tests.Common.Mock;
|
||||||
|
|
||||||
|
@ -61,12 +62,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
|
// Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
|
||||||
|
Util.FireAndForgetMethod = FireAndForgetMethod.None;
|
||||||
|
|
||||||
ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
|
scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
|
||||||
interregionComms.Initialise(new IniConfigSource());
|
SceneHelpers.SetupSceneModules(scene, new AttachmentsModule());
|
||||||
interregionComms.PostInitialise();
|
|
||||||
SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
|
|
||||||
|
|
||||||
agent1 = UUID.Random();
|
agent1 = UUID.Random();
|
||||||
random = new Random();
|
random = new Random();
|
||||||
|
@ -74,6 +74,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||||
sog2 = NewSOG(UUID.Random(), scene, agent1);
|
sog2 = NewSOG(UUID.Random(), scene, agent1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TearDown]
|
||||||
|
public void TearDown()
|
||||||
|
{
|
||||||
|
// We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
|
||||||
|
// threads. Possibly, later tests should be rewritten not to worry about such things.
|
||||||
|
Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestAddAttachments()
|
public void TestAddAttachments()
|
||||||
{
|
{
|
||||||
|
@ -100,11 +108,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||||
Assert.That(presence.HasAttachments(), Is.False);
|
Assert.That(presence.HasAttachments(), Is.False);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Test]
|
[Test]
|
||||||
// public void TestRezAttachmentsOnAvatarEntrance()
|
public void TestRezAttachmentsOnAvatarEntrance()
|
||||||
// {
|
{
|
||||||
// ScenePresence presence = scene.GetScenePresence(agent1);
|
TestHelpers.InMethod();
|
||||||
// }
|
// log4net.Config.XmlConfigurator.Configure();
|
||||||
|
|
||||||
|
UUID spId = TestHelpers.ParseTail(0x1);
|
||||||
|
UUID attItemId = TestHelpers.ParseTail(0x2);
|
||||||
|
UUID attAssetId = TestHelpers.ParseTail(0x3);
|
||||||
|
|
||||||
|
AgentCircuitData acd = SceneHelpers.GenerateAgentData(spId);
|
||||||
|
acd.Appearance = new AvatarAppearance();
|
||||||
|
acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItemId, attAssetId);
|
||||||
|
ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
|
||||||
|
|
||||||
|
// Assert.That(presence.HasAttachments(), Is.True);
|
||||||
|
}
|
||||||
|
|
||||||
// I'm commenting this test because scene setup NEEDS InventoryService to
|
// I'm commenting this test because scene setup NEEDS InventoryService to
|
||||||
// be non-null
|
// be non-null
|
||||||
|
|
Loading…
Reference in New Issue