Fixed potential grid thread deadlock
This commit is contained in:
parent
5d10f1412f
commit
60f13cabe8
2 changed files with 11 additions and 14 deletions
|
@ -21,24 +21,21 @@ public abstract class NodeGrid<N extends Node> extends Grid<N>
|
|||
|
||||
AbstractMap<Object, ForgeDirection> connections = node.getConnections();
|
||||
|
||||
synchronized (connections)
|
||||
for (Object connection : connections.keySet())
|
||||
{
|
||||
for (Object connection : connections.keySet())
|
||||
if (isValidNode(connection) && connection instanceof Node)
|
||||
{
|
||||
if (isValidNode(connection) && connection instanceof Node)
|
||||
Node connectedNode = (Node) connection;
|
||||
|
||||
if (connectedNode.getGrid() != this)
|
||||
{
|
||||
Node connectedNode = (Node) connection;
|
||||
|
||||
if (connectedNode.getGrid() != this)
|
||||
synchronized (connectedNode.getGrid().getNodes())
|
||||
{
|
||||
synchronized (connectedNode.getGrid().getNodes())
|
||||
{
|
||||
connectedNode.getGrid().getNodes().clear();
|
||||
}
|
||||
|
||||
add((N) connectedNode);
|
||||
reconstructNode((N) connectedNode);
|
||||
connectedNode.getGrid().getNodes().clear();
|
||||
}
|
||||
|
||||
add((N) connectedNode);
|
||||
reconstructNode((N) connectedNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class TickingGrid<N extends Node> extends NodeGrid<N> implements IUpdate
|
|||
@Override
|
||||
public void update()
|
||||
{
|
||||
// synchronized (nodes)
|
||||
synchronized (nodes)
|
||||
{
|
||||
for (Node node : nodes)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue