Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Sandbox.Game.MyInventory.IsConnected(..) is not Thread safe #572

Open
Dummy0815 opened this issue Jan 2, 2017 · 1 comment
Open

Sandbox.Game.MyInventory.IsConnected(..) is not Thread safe #572

Dummy0815 opened this issue Jan 2, 2017 · 1 comment

Comments

@Dummy0815
Copy link

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; }

@ESearcy
Copy link

ESearcy commented Feb 3, 2017

Make a PR for it. with this as the desc.
As long as the fix and need is clear/easy to make I'm sure they'd consider pulling it in.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants