v0.9.2b: simplified thread coordination to reduce deadlock risk
This commit is contained in:
@@ -26,7 +26,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
|
||||||
import com.watabou.utils.Bundlable;
|
import com.watabou.utils.Bundlable;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.SparseArray;
|
import com.watabou.utils.SparseArray;
|
||||||
@@ -283,11 +282,9 @@ public abstract class Actor implements Bundlable {
|
|||||||
current = null;
|
current = null;
|
||||||
interrupted = false;
|
interrupted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (GameScene.class){
|
//signals to the gamescene that actor processing is finished for now
|
||||||
//signals to the gamescene that actor processing is finished for now
|
Thread.currentThread().notify();
|
||||||
GameScene.class.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.currentThread().wait();
|
Thread.currentThread().wait();
|
||||||
|
|||||||
@@ -555,21 +555,17 @@ public class GameScene extends PixelScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean waitForActorThread(int msToWait ){
|
public boolean waitForActorThread(int msToWait ){
|
||||||
synchronized (GameScene.class) {
|
if (actorThread == null || !actorThread.isAlive()) {
|
||||||
if (actorThread == null || !actorThread.isAlive()) {
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
synchronized (actorThread) {
|
||||||
synchronized (actorThread) {
|
actorThread.interrupt();
|
||||||
actorThread.interrupt();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
GameScene.class.wait(msToWait);
|
actorThread.wait(msToWait);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
ShatteredPixelDungeon.reportException(e);
|
ShatteredPixelDungeon.reportException(e);
|
||||||
}
|
}
|
||||||
synchronized (actorThread) {
|
return !Actor.processing();
|
||||||
return !Actor.processing();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user