Fixed #41/2

Removed min hard cap for MaxDegreeOfParallelism
This commit is contained in:
NotAlwaysTrue
2026-01-16 17:15:57 +08:00
parent e7e444e9b2
commit e24024cbb2
5 changed files with 14 additions and 7 deletions

View File

@@ -25,7 +25,7 @@ namespace Barotrauma
private static readonly ParallelOptions parallelOptions = new ParallelOptions
{
MaxDegreeOfParallelism = Math.Max(4,Environment.ProcessorCount - 1),
MaxDegreeOfParallelism = Math.Max(1,Environment.ProcessorCount - 1),
};
#if CLIENT

View File

@@ -1145,4 +1145,4 @@ namespace FarseerPhysics.Collision
}
}
}
}
}

View File

@@ -27,9 +27,10 @@
* 3. This notice may not be removed or altered from any source distribution.
*/
using System.Collections.Generic;
using FarseerPhysics.Collision;
using FarseerPhysics.Dynamics.Contacts;
using System.Collections.Generic;
using System.Threading;
namespace FarseerPhysics.Dynamics
{
@@ -61,6 +62,8 @@ namespace FarseerPhysics.Dynamics
public int CollideMultithreadThreshold = 64;
#endregion
// This will ensure only one thread will work on ContactList so that we wont mess up these stuff
private readonly SemaphoreSlim contactManagerSignal = new SemaphoreSlim(1);
/// <summary>
/// Fires when a contact is created
@@ -249,6 +252,8 @@ namespace FarseerPhysics.Dynamics
internal void Destroy(Contact contact)
{
contactManagerSignal.Wait(100);
Fixture fixtureA = contact.FixtureA;
Fixture fixtureB = contact.FixtureB;
Body bodyA = fixtureA.Body;
@@ -310,6 +315,8 @@ namespace FarseerPhysics.Dynamics
// Insert into the pool.
contact.Next = _contactPoolList.Next;
_contactPoolList.Next = contact;
contactManagerSignal.Release();
}
internal void Collide()
@@ -610,4 +617,4 @@ namespace FarseerPhysics.Dynamics
}
#endif
}
}
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2017 Kastellanos Nikolaos
// Copyright (c) 2017 Kastellanos Nikolaos
/* Original source Farseer Physics Engine:
* Copyright (c) 2014 Ian Qvist, http://farseerphysics.codeplex.com
@@ -496,4 +496,4 @@ namespace FarseerPhysics.Dynamics.Contacts
#endregion
}
}
}

View File

@@ -1726,4 +1726,4 @@ namespace FarseerPhysics.Dynamics
}
}
}
}