From dc2d32ebe039c7251cf07da4b3bd00d4152c772a Mon Sep 17 00:00:00 2001 From: metalgearsloth Date: Thu, 22 Aug 2024 21:25:02 +1000 Subject: [PATCH] Stop inheriting IThreadPoolWorkitem More annoying with internal changes. --- Robust.Shared/Threading/IRobustJob.cs | 3 ++- Robust.Shared/Threading/ParallelManager.cs | 11 +++++++++-- Robust.UnitTesting/TestingParallelManager.cs | 5 +++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Robust.Shared/Threading/IRobustJob.cs b/Robust.Shared/Threading/IRobustJob.cs index c84f8cb2c71..83565ac67b9 100644 --- a/Robust.Shared/Threading/IRobustJob.cs +++ b/Robust.Shared/Threading/IRobustJob.cs @@ -5,6 +5,7 @@ namespace Robust.Shared.Threading; /// /// Implement for code that needs to be runnable on a threadpool. /// -public interface IRobustJob : IThreadPoolWorkItem +public interface IRobustJob { + void Execute(); } diff --git a/Robust.Shared/Threading/ParallelManager.cs b/Robust.Shared/Threading/ParallelManager.cs index f461b22c305..8d87853e584 100644 --- a/Robust.Shared/Threading/ParallelManager.cs +++ b/Robust.Shared/Threading/ParallelManager.cs @@ -24,6 +24,8 @@ public interface IParallelManager /// WaitHandle Process(IRobustJob job); + public void ProcessNow(IRobustJob job); + /// /// Takes in a parallel job and runs it the specified amount. /// @@ -123,6 +125,11 @@ public WaitHandle Process(IRobustJob job) return subJob.Event.WaitHandle; } + public void ProcessNow(IRobustJob job) + { + job.Execute(); + } + /// public void ProcessNow(IParallelRobustJob job, int amount) { @@ -195,7 +202,7 @@ private ParallelTracker InternalProcess(IParallelRobustJob job, int amount) /// /// Runs an and handles cleanup. /// - private sealed class InternalJob : IRobustJob + private sealed class InternalJob : IRobustJob, IThreadPoolWorkItem { private ISawmill _sawmill = default!; private IRobustJob _robust = default!; @@ -231,7 +238,7 @@ public void Execute() /// /// Runs an and handles cleanup. /// - private sealed class InternalParallelJob : IRobustJob + private sealed class InternalParallelJob : IRobustJob, IThreadPoolWorkItem { private IParallelRobustJob _robust = default!; private int _start; diff --git a/Robust.UnitTesting/TestingParallelManager.cs b/Robust.UnitTesting/TestingParallelManager.cs index 0c2907f8ec9..2434514f25a 100644 --- a/Robust.UnitTesting/TestingParallelManager.cs +++ b/Robust.UnitTesting/TestingParallelManager.cs @@ -26,6 +26,11 @@ WaitHandle IParallelManager.Process(IRobustJob job) return ev.WaitHandle; } + public void ProcessNow(IRobustJob job) + { + job.Execute(); + } + /// public void ProcessNow(IParallelRobustJob jobs, int amount) {