Skip to content

Commit

Permalink
Stop inheriting IThreadPoolWorkitem
Browse files Browse the repository at this point in the history
More annoying with internal changes.
  • Loading branch information
metalgearsloth committed Aug 22, 2024
1 parent f03c006 commit dc2d32e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Robust.Shared/Threading/IRobustJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Robust.Shared.Threading;
/// <summary>
/// Implement for code that needs to be runnable on a threadpool.
/// </summary>
public interface IRobustJob : IThreadPoolWorkItem
public interface IRobustJob
{
void Execute();
}
11 changes: 9 additions & 2 deletions Robust.Shared/Threading/ParallelManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public interface IParallelManager
/// <param name="job"></param>
WaitHandle Process(IRobustJob job);

public void ProcessNow(IRobustJob job);

/// <summary>
/// Takes in a parallel job and runs it the specified amount.
/// </summary>
Expand Down Expand Up @@ -123,6 +125,11 @@ public WaitHandle Process(IRobustJob job)
return subJob.Event.WaitHandle;
}

public void ProcessNow(IRobustJob job)
{
job.Execute();
}

/// <inheritdoc/>
public void ProcessNow(IParallelRobustJob job, int amount)
{
Expand Down Expand Up @@ -195,7 +202,7 @@ private ParallelTracker InternalProcess(IParallelRobustJob job, int amount)
/// <summary>
/// Runs an <see cref="IRobustJob"/> and handles cleanup.
/// </summary>
private sealed class InternalJob : IRobustJob
private sealed class InternalJob : IRobustJob, IThreadPoolWorkItem
{
private ISawmill _sawmill = default!;
private IRobustJob _robust = default!;
Expand Down Expand Up @@ -231,7 +238,7 @@ public void Execute()
/// <summary>
/// Runs an <see cref="IParallelRobustJob"/> and handles cleanup.
/// </summary>
private sealed class InternalParallelJob : IRobustJob
private sealed class InternalParallelJob : IRobustJob, IThreadPoolWorkItem
{
private IParallelRobustJob _robust = default!;
private int _start;
Expand Down
5 changes: 5 additions & 0 deletions Robust.UnitTesting/TestingParallelManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ WaitHandle IParallelManager.Process(IRobustJob job)
return ev.WaitHandle;
}

public void ProcessNow(IRobustJob job)
{
job.Execute();
}

/// <inheritdoc/>
public void ProcessNow(IParallelRobustJob jobs, int amount)
{
Expand Down

0 comments on commit dc2d32e

Please sign in to comment.