Skip to content

Commit

Permalink
simplified ASystem code path
Browse files Browse the repository at this point in the history
  • Loading branch information
Doraku committed Jun 14, 2018
1 parent cf74372 commit c8a33da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 2 additions & 9 deletions source/DefaultEcs/System/ASystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public abstract class ASystem<T> : ISystem<T>
/// <param name="runner">The <see cref="SystemRunner{T}"/> used to process the update in parallel if not null.</param>
protected ASystem(SystemRunner<T> runner)
{
_runner = runner;
_runner = runner ?? SystemRunner<T>.Default;
}

/// <summary>
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion source/DefaultEcs/System/SystemRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public sealed class SystemRunner<T> : IDisposable
{
#region Fields

internal static readonly SystemRunner<T> Default = new SystemRunner<T>(1);

private readonly CancellationTokenSource _disposeHandle;
private readonly ManualResetEventSlim[] _startHandles;
private readonly ManualResetEventSlim[] _endHandles;
Expand Down Expand Up @@ -81,7 +83,7 @@ internal void Update(T state, ASystem<T> system)
handle.Set();
}

_currentSystem.Update(_currentState, _tasks.Length, _tasks.Length);
system.Update(state, _tasks.Length, _tasks.Length);

foreach (ManualResetEventSlim handle in _endHandles)
{
Expand Down

0 comments on commit c8a33da

Please sign in to comment.