You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.
As the 'reachableVertices' list is declare as field the usage of this list inside IsConnected is not Thread safe.
The list is only used inside the function and cleared before every usage, I suggest to use an local list instead.
This will make the function Thread safe and will also reduce memory usage.
private bool IsConnected(MyInventory dstInventory) { var srcConveyor = (this.Owner as IMyConveyorEndpointBlock); if (srcConveyor != null) { var reachableVertices = new List<IMyConveyorEndpoint>(); MyGridConveyorSystem.FindReachable(srcConveyor.ConveyorEndpoint, reachableVertices, (vertex) => vertex.CubeBlock != null); foreach (var vertex in reachableVertices) { if (dstInventory.Owner == vertex.CubeBlock) { return true; } } } return false; }
The text was updated successfully, but these errors were encountered:
As the 'reachableVertices' list is declare as field the usage of this list inside IsConnected is not Thread safe.
The list is only used inside the function and cleared before every usage, I suggest to use an local list instead.
This will make the function Thread safe and will also reduce memory usage.
private bool IsConnected(MyInventory dstInventory) { var srcConveyor = (this.Owner as IMyConveyorEndpointBlock); if (srcConveyor != null) { var reachableVertices = new List<IMyConveyorEndpoint>(); MyGridConveyorSystem.FindReachable(srcConveyor.ConveyorEndpoint, reachableVertices, (vertex) => vertex.CubeBlock != null); foreach (var vertex in reachableVertices) { if (dstInventory.Owner == vertex.CubeBlock) { return true; } } } return false; }
The text was updated successfully, but these errors were encountered: