diff --git a/source/DefaultEcs/System/ASystem.cs b/source/DefaultEcs/System/ASystem.cs index d8969e67..2fbf1ea7 100644 --- a/source/DefaultEcs/System/ASystem.cs +++ b/source/DefaultEcs/System/ASystem.cs @@ -20,7 +20,7 @@ public abstract class ASystem : ISystem /// The used to process the update in parallel if not null. protected ASystem(SystemRunner runner) { - _runner = runner; + _runner = runner ?? SystemRunner.Default; } /// @@ -60,14 +60,7 @@ public void Update(T state) { PreUpdate(state); - if (_runner != null) - { - _runner.Update(state, this); - } - else - { - Update(state, 0, 0); - } + _runner.Update(state, this); PostUpdate(state); } diff --git a/source/DefaultEcs/System/SystemRunner.cs b/source/DefaultEcs/System/SystemRunner.cs index a4e6abf0..bca1ed12 100644 --- a/source/DefaultEcs/System/SystemRunner.cs +++ b/source/DefaultEcs/System/SystemRunner.cs @@ -15,6 +15,8 @@ public sealed class SystemRunner : IDisposable { #region Fields + internal static readonly SystemRunner Default = new SystemRunner(1); + private readonly CancellationTokenSource _disposeHandle; private readonly ManualResetEventSlim[] _startHandles; private readonly ManualResetEventSlim[] _endHandles; @@ -81,7 +83,7 @@ internal void Update(T state, ASystem system) handle.Set(); } - _currentSystem.Update(_currentState, _tasks.Length, _tasks.Length); + system.Update(state, _tasks.Length, _tasks.Length); foreach (ManualResetEventSlim handle in _endHandles) {