Synchronization
This commit is contained in:
@@ -28,7 +28,7 @@ public class PowerGraph{
|
|||||||
return graphID;
|
return graphID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(){
|
public synchronized void update(){
|
||||||
if(threads.getFrameID() == lastFrameUpdated || consumers.size == 0 || producers.size == 0){
|
if(threads.getFrameID() == lastFrameUpdated || consumers.size == 0 || producers.size == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -70,13 +70,13 @@ public class PowerGraph{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(PowerGraph graph){
|
public synchronized void add(PowerGraph graph){
|
||||||
for(Tile tile : graph.all){
|
for(Tile tile : graph.all){
|
||||||
add(tile);
|
add(tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(Tile tile){
|
public synchronized void add(Tile tile){
|
||||||
tile.entity.power.graph = this;
|
tile.entity.power.graph = this;
|
||||||
all.add(tile);
|
all.add(tile);
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ public class PowerGraph{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear(){
|
public synchronized void clear(){
|
||||||
for(Tile other : all){
|
for(Tile other : all){
|
||||||
other.entity.power.graph = null;
|
other.entity.power.graph = null;
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ public class PowerGraph{
|
|||||||
consumers.clear();
|
consumers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reflow(Tile tile){
|
public synchronized void reflow(Tile tile){
|
||||||
queue.clear();
|
queue.clear();
|
||||||
queue.addLast(tile);
|
queue.addLast(tile);
|
||||||
while(queue.size > 0){
|
while(queue.size > 0){
|
||||||
@@ -113,7 +113,7 @@ public class PowerGraph{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(Tile tile){
|
public synchronized void remove(Tile tile){
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
for(Tile other : tile.block().getPowerConnections(tile, outArray1)){
|
for(Tile other : tile.block().getPowerConnections(tile, outArray1)){
|
||||||
|
|||||||
Reference in New Issue
Block a user