Skip to content

Commit

Permalink
Back to genaray
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth committed Nov 22, 2023
1 parent 2ecc72c commit 03b0b98
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "cefglue"]
path = cefglue
url = https://github.com/space-wizards/cefglue.git
[submodule "ZeroAllocJobScheduler"]
path = ZeroAllocJobScheduler
url = https://github.com/genaray/ZeroAllocJobScheduler
14 changes: 5 additions & 9 deletions Robust.Shared/Threading/ParallelManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface IParallelManager
/// Takes in a job that gets flushed.
/// </summary>
/// <param name="job"></param>
ValueTask Process(IRobustJob job);
JobHandle Process(IRobustJob job);

/// <summary>
/// Takes in a parallel job and runs it the specified amount.
Expand All @@ -38,7 +38,7 @@ public interface IParallelManager
/// <summary>
/// Takes in a parallel job and runs it without blocking.
/// </summary>
ValueTask Process(IParallelRobustJob jobs, int amount);
JobHandle Process(IParallelRobustJob jobs, int amount);

/// <summary>
/// Waits for the specified job handles to finish.
Expand All @@ -64,10 +64,6 @@ public void Initialize()
{
_cfg.OnValueChanged(CVars.ThreadParallelCount, UpdateCVar, true);

// TODO: Finish porting the other big parallel methods.
// TODO: Try using ValueTask returns and see if it's okay.
// If it is then try swapping JobScheduler back out for Threadpool

_scheduler = new JobScheduler(new JobScheduler.Config()
{
ThreadCount = ParallelProcessCount,
Expand All @@ -93,7 +89,7 @@ private void UpdateCVar(int value)
}
}

public ValueTask Process(IRobustJob job)
public JobHandle Process(IRobustJob job)
{
var handle = _scheduler.Schedule(job);
_scheduler.Flush();
Expand All @@ -103,7 +99,7 @@ public ValueTask Process(IRobustJob job)
public void ProcessNow(IParallelRobustJob job, int amount)
{
var handle = Process(job, amount);
handle.AsTask().Wait();
handle.Complete();
}

public void ProcessSerialNow(IParallelRobustJob jobs, int amount)
Expand All @@ -114,7 +110,7 @@ public void ProcessSerialNow(IParallelRobustJob jobs, int amount)
}
}

public ValueTask Process(IParallelRobustJob job, int amount)
public JobHandle Process(IParallelRobustJob job, int amount)
{
var handle = _scheduler.Schedule(job, amount);
_scheduler.Flush();
Expand Down
1 change: 1 addition & 0 deletions ZeroAllocJobScheduler
Submodule ZeroAllocJobScheduler added at 52b8ba

0 comments on commit 03b0b98

Please sign in to comment.