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