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.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.watabou.utils.Bundlable;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.SparseArray;
|
||||
@@ -283,11 +282,9 @@ public abstract class Actor implements Bundlable {
|
||||
current = null;
|
||||
interrupted = false;
|
||||
}
|
||||
|
||||
synchronized (GameScene.class){
|
||||
//signals to the gamescene that actor processing is finished for now
|
||||
GameScene.class.notify();
|
||||
}
|
||||
|
||||
//signals to the gamescene that actor processing is finished for now
|
||||
Thread.currentThread().notify();
|
||||
|
||||
try {
|
||||
Thread.currentThread().wait();
|
||||
|
||||
@@ -555,21 +555,17 @@ public class GameScene extends PixelScene {
|
||||
}
|
||||
|
||||
public boolean waitForActorThread(int msToWait ){
|
||||
synchronized (GameScene.class) {
|
||||
if (actorThread == null || !actorThread.isAlive()) {
|
||||
return true;
|
||||
}
|
||||
synchronized (actorThread) {
|
||||
actorThread.interrupt();
|
||||
}
|
||||
if (actorThread == null || !actorThread.isAlive()) {
|
||||
return true;
|
||||
}
|
||||
synchronized (actorThread) {
|
||||
actorThread.interrupt();
|
||||
try {
|
||||
GameScene.class.wait(msToWait);
|
||||
actorThread.wait(msToWait);
|
||||
} catch (InterruptedException e) {
|
||||
ShatteredPixelDungeon.reportException(e);
|
||||
}
|
||||
synchronized (actorThread) {
|
||||
return !Actor.processing();
|
||||
}
|
||||
return !Actor.processing();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user