Fixed some thread race issues
This commit is contained in:
parent
9b6ba3d086
commit
b2fc0d87a7
4 changed files with 27 additions and 20 deletions
|
|
@ -162,9 +162,11 @@ public class UeControlExecutor implements Runnable{
|
||||||
currentlyActive = null;
|
currentlyActive = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(csvLogger != null){
|
synchronized (csvLogger) {
|
||||||
csvLogger.flush();
|
if (csvLogger != null) {
|
||||||
csvLogger = null;
|
csvLogger.flush();
|
||||||
|
csvLogger = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
log.info("Execution completed");
|
log.info("Execution completed");
|
||||||
if(execListener != null)
|
if(execListener != null)
|
||||||
|
|
@ -236,10 +238,12 @@ public class UeControlExecutor implements Runnable{
|
||||||
downloadSpeed.setHandledData(0);
|
downloadSpeed.setHandledData(0);
|
||||||
}
|
}
|
||||||
if (uploadSpeed.isUpdated()) {
|
if (uploadSpeed.isUpdated()) {
|
||||||
if(csvLogger != null)
|
synchronized (csvLogger) {
|
||||||
csvLogger.write(getRunningBehaviour().getName(),
|
if (csvLogger != null)
|
||||||
downloadSpeed.getBitThroughput(),
|
csvLogger.write(getRunningBehaviour().getName(),
|
||||||
uploadSpeed.getBitThroughput());
|
downloadSpeed.getBitThroughput(),
|
||||||
|
uploadSpeed.getBitThroughput());
|
||||||
|
}
|
||||||
if (throughputListener != null)
|
if (throughputListener != null)
|
||||||
throughputListener.throughputUpdate(
|
throughputListener.throughputUpdate(
|
||||||
downloadSpeed.getBitThroughput(),
|
downloadSpeed.getBitThroughput(),
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,16 @@ public class UeBehaviourIterator extends UeBehaviour {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute() throws Exception {
|
protected void execute() throws Exception {
|
||||||
iterationCount++;
|
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
|
||||||
if(iterationCount < iterations){
|
if(!super.stopExecution()) {
|
||||||
log.debug("Iteration: "+ iterationCount);
|
iterationCount++;
|
||||||
super.getExecutor().setNextBehaviour(0);
|
if (iterationCount < iterations) {
|
||||||
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
|
log.debug("Iteration: " + iterationCount);
|
||||||
}
|
super.getExecutor().setNextBehaviour(0);
|
||||||
else{
|
} else {
|
||||||
log.debug("Iteration done, skipping");
|
log.debug("Iteration done, skipping");
|
||||||
|
iterationCount = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,12 @@ public class UeBehaviourStop extends UeBehaviour {
|
||||||
@Override
|
@Override
|
||||||
protected void execute() throws Exception {
|
protected void execute() throws Exception {
|
||||||
UeControlExecutor executor = super.getExecutor();
|
UeControlExecutor executor = super.getExecutor();
|
||||||
log.debug("Terminating executor");
|
|
||||||
executor.terminateNonBlock();
|
|
||||||
log.debug("Resetting executor");
|
|
||||||
executor.reset();
|
|
||||||
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
|
Thread.sleep(VISUAL_SLEEP_PERIOD); // Sleep as a visual queue
|
||||||
|
|
||||||
|
if(!super.stopExecution()) {
|
||||||
|
log.debug("Terminating executor");
|
||||||
|
executor.terminateNonBlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ public class ExecNotification {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void update(double downThroughput, double upThroughput){
|
public static void update(double downThroughput, double upThroughput){
|
||||||
if(mBuilder != null) {
|
if(mBuilder != null && MainActivity.getExecutor().getRunningBehaviour() != null) {
|
||||||
mBuilder.setContentTitle("Exec Behaviour: " + MainActivity.getExecutor().getRunningBehaviour().getName());
|
mBuilder.setContentTitle("Exec Behaviour: " + MainActivity.getExecutor().getRunningBehaviour().getName());
|
||||||
mBuilder.setContentText(" Down: " + StringUtil.getBitThroughputString(downThroughput)
|
mBuilder.setContentText(" Down: " + StringUtil.getBitThroughputString(downThroughput)
|
||||||
+ " Up: " + StringUtil.getBitThroughputString(upThroughput));
|
+ " Up: " + StringUtil.getBitThroughputString(upThroughput));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue