v0.6.0a: further improvements/fixes to threading logic
This commit is contained in:
@@ -179,8 +179,10 @@ public abstract class Actor implements Bundlable {
|
|||||||
boolean interrupted = false;
|
boolean interrupted = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
now = Float.MAX_VALUE;
|
|
||||||
current = null;
|
current = null;
|
||||||
|
if (!interrupted) {
|
||||||
|
now = Float.MAX_VALUE;
|
||||||
|
|
||||||
for (Actor actor : all) {
|
for (Actor actor : all) {
|
||||||
|
|
||||||
@@ -192,8 +194,9 @@ public abstract class Actor implements Bundlable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!interrupted && current != null) {
|
if (current != null) {
|
||||||
|
|
||||||
Actor acting = current;
|
Actor acting = current;
|
||||||
|
|
||||||
@@ -228,6 +231,7 @@ public abstract class Actor implements Bundlable {
|
|||||||
|
|
||||||
synchronized (Thread.currentThread()) {
|
synchronized (Thread.currentThread()) {
|
||||||
synchronized (GameScene.class){
|
synchronized (GameScene.class){
|
||||||
|
//signals to the gamescene that actor processing is finished for now
|
||||||
GameScene.class.notify();
|
GameScene.class.notify();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -416,11 +416,10 @@ public class GameScene extends PixelScene {
|
|||||||
|
|
||||||
//tell the actor thread to finish, then wait for it to complete any actions it may be doing.
|
//tell the actor thread to finish, then wait for it to complete any actions it may be doing.
|
||||||
if (actorThread.isAlive()){
|
if (actorThread.isAlive()){
|
||||||
|
synchronized (GameScene.class){
|
||||||
synchronized (actorThread) {
|
synchronized (actorThread) {
|
||||||
actorThread.interrupt();
|
actorThread.interrupt();
|
||||||
}
|
}
|
||||||
synchronized (GameScene.class){
|
|
||||||
if (actorThread.getState() != Thread.State.WAITING) {
|
|
||||||
try {
|
try {
|
||||||
GameScene.class.wait(5000);
|
GameScene.class.wait(5000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -435,7 +434,6 @@ public class GameScene extends PixelScene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
freezeEmitters = false;
|
freezeEmitters = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user