From db94e68d2fe32c88916c383fba0be6d79c1895da Mon Sep 17 00:00:00 2001 From: Laurent Clouet Date: Tue, 2 Dec 2014 20:28:03 +0000 Subject: [PATCH] Improvement: add call for pause/resume client --- src/com/sheepit/client/Client.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/com/sheepit/client/Client.java b/src/com/sheepit/client/Client.java index 35c5ba3..406795e 100644 --- a/src/com/sheepit/client/Client.java +++ b/src/com/sheepit/client/Client.java @@ -60,6 +60,7 @@ public class Client { private boolean disableErrorSending; private boolean running; + private boolean suspended; public Client(Gui gui_, Configuration config, String url_) { this.config = config; @@ -72,6 +73,7 @@ public class Client { this.disableErrorSending = false; this.running = true; + this.suspended = false; } public String toString() { @@ -123,6 +125,11 @@ public class Client { this.renderingJob = null; while (this.running == true) { + synchronized(this) { + while(this.suspended) { + wait(); + } + } step = this.log.newCheckPoint(); try { Calendar next_request = this.nextJobRequest(); @@ -302,6 +309,15 @@ public class Client { return 0; } + public void suspend() { + suspended = true; + } + + public synchronized void resume() { + suspended = false; + notify(); + } + public void askForStop() { System.out.println("Client::askForStop"); this.running = false;