Remove IoCManager.InitThread calls from parallel code. (#13070)
This commit is contained in:
committed by
GitHub
parent
cd803a82bd
commit
4fa2920472
@@ -1,6 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Shared.Atmos;
|
||||
@@ -255,17 +254,11 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
// Afterwards we reset all the chunk data for the next time we tick.
|
||||
var players = _playerManager.ServerSessions.Where(x => x.Status == SessionStatus.InGame).ToArray();
|
||||
var opts = new ParallelOptions { MaxDegreeOfParallelism = _parMan.ParallelProcessCount };
|
||||
var mainThread = Thread.CurrentThread;
|
||||
var parentDeps = IoCManager.Instance!;
|
||||
Parallel.ForEach(players, opts, p => UpdatePlayer(p, curTick, mainThread, parentDeps));
|
||||
Parallel.ForEach(players, opts, p => UpdatePlayer(p, curTick));
|
||||
}
|
||||
|
||||
private void UpdatePlayer(IPlayerSession playerSession, GameTick curTick, Thread mainThread, IDependencyCollection parentDeps)
|
||||
private void UpdatePlayer(IPlayerSession playerSession, GameTick curTick)
|
||||
{
|
||||
// Thjs exists JUST to be able to resolve IRobustStringSerializer for networked message sending.
|
||||
if (mainThread != Thread.CurrentThread)
|
||||
IoCManager.InitThread(parentDeps.FromParent(parentDeps), true);
|
||||
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var chunksInRange = _chunkingSys.GetChunksForSession(playerSession, ChunkSize, xformQuery, _chunkIndexPool, _chunkViewerPool);
|
||||
var previouslySent = _lastSentChunks[playerSession];
|
||||
|
||||
Reference in New Issue
Block a user