mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Enforce integration instance idleness for more helper members
Also allow them to be accessed regardless if from the integration instance thread.
This commit is contained in:
@@ -35,7 +35,7 @@ END TEMPLATE-->
|
||||
|
||||
### Breaking changes
|
||||
|
||||
*None yet*
|
||||
* More members in `IntegrationInstance` now enforce that the instance is idle before accessing it.
|
||||
|
||||
### New features
|
||||
|
||||
@@ -48,6 +48,7 @@ END TEMPLATE-->
|
||||
### Other
|
||||
|
||||
* The configuration system will now report an error instead of warning if it fails to load the config file.
|
||||
* Members in `IntegrationInstance` that enforce the instance is idle now always allow access from the instance's thread (e.g. from a callback).
|
||||
|
||||
### Internal
|
||||
|
||||
|
||||
@@ -337,6 +337,8 @@ namespace Robust.UnitTesting
|
||||
[Pure]
|
||||
public T System<T>() where T : IEntitySystem
|
||||
{
|
||||
CheckThreadOrIdle();
|
||||
|
||||
return EntMan.System<T>();
|
||||
}
|
||||
|
||||
@@ -345,11 +347,15 @@ namespace Robust.UnitTesting
|
||||
|
||||
public TransformComponent Transform(EntityUid uid)
|
||||
{
|
||||
CheckThreadOrIdle();
|
||||
|
||||
return EntMan.GetComponent<TransformComponent>(uid);
|
||||
}
|
||||
|
||||
public MetaDataComponent MetaData(EntityUid uid)
|
||||
{
|
||||
CheckThreadOrIdle();
|
||||
|
||||
return EntMan.GetComponent<MetaDataComponent>(uid);
|
||||
}
|
||||
|
||||
@@ -369,11 +375,7 @@ namespace Robust.UnitTesting
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_isSurelyIdle)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Cannot read this without ensuring that the instance is idle.");
|
||||
}
|
||||
CheckThreadOrIdle();
|
||||
|
||||
return _isAlive;
|
||||
}
|
||||
@@ -389,11 +391,7 @@ namespace Robust.UnitTesting
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_isSurelyIdle)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Cannot read this without ensuring that the instance is idle.");
|
||||
}
|
||||
CheckThreadOrIdle();
|
||||
|
||||
return _unhandledException;
|
||||
}
|
||||
@@ -435,11 +433,7 @@ namespace Robust.UnitTesting
|
||||
[Pure]
|
||||
public T ResolveDependency<T>()
|
||||
{
|
||||
if (!_isSurelyIdle)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Cannot resolve services without ensuring that the instance is idle.");
|
||||
}
|
||||
CheckThreadOrIdle();
|
||||
|
||||
return DependencyCollection.Resolve<T>();
|
||||
}
|
||||
@@ -638,6 +632,18 @@ namespace Robust.UnitTesting
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckThreadOrIdle()
|
||||
{
|
||||
if (_isSurelyIdle)
|
||||
return;
|
||||
|
||||
if (Thread.CurrentThread == InstanceThread)
|
||||
return;
|
||||
|
||||
throw new InvalidOperationException(
|
||||
"Cannot perform this operation without ensuring the instance is idle.");
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ServerIntegrationInstance : IntegrationInstance, IServerIntegrationInstance
|
||||
|
||||
Reference in New Issue
Block a user