Improvement: add call for pause/resume client

This commit is contained in:
Laurent Clouet
2014-12-02 20:28:03 +00:00
parent 4de029b3a8
commit db94e68d2f

View File

@@ -60,6 +60,7 @@ public class Client {
private boolean disableErrorSending; private boolean disableErrorSending;
private boolean running; private boolean running;
private boolean suspended;
public Client(Gui gui_, Configuration config, String url_) { public Client(Gui gui_, Configuration config, String url_) {
this.config = config; this.config = config;
@@ -72,6 +73,7 @@ public class Client {
this.disableErrorSending = false; this.disableErrorSending = false;
this.running = true; this.running = true;
this.suspended = false;
} }
public String toString() { public String toString() {
@@ -123,6 +125,11 @@ public class Client {
this.renderingJob = null; this.renderingJob = null;
while (this.running == true) { while (this.running == true) {
synchronized(this) {
while(this.suspended) {
wait();
}
}
step = this.log.newCheckPoint(); step = this.log.newCheckPoint();
try { try {
Calendar next_request = this.nextJobRequest(); Calendar next_request = this.nextJobRequest();
@@ -302,6 +309,15 @@ public class Client {
return 0; return 0;
} }
public void suspend() {
suspended = true;
}
public synchronized void resume() {
suspended = false;
notify();
}
public void askForStop() { public void askForStop() {
System.out.println("Client::askForStop"); System.out.println("Client::askForStop");
this.running = false; this.running = false;