From 3aeaf86b1a1852b8876893153f8bb38702d5eb9b Mon Sep 17 00:00:00 2001 From: fros4943 Date: Wed, 3 Feb 2010 15:33:36 +0000 Subject: [PATCH] added a method for pausing the simulation that doesn't block --- .../cooja/java/se/sics/cooja/Simulation.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/cooja/java/se/sics/cooja/Simulation.java b/tools/cooja/java/se/sics/cooja/Simulation.java index 33bb3db64..b9c7d8f3a 100644 --- a/tools/cooja/java/se/sics/cooja/Simulation.java +++ b/tools/cooja/java/se/sics/cooja/Simulation.java @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: Simulation.java,v 1.59 2010/02/03 12:15:37 fros4943 Exp $ + * $Id: Simulation.java,v 1.60 2010/02/03 15:33:36 fros4943 Exp $ */ package se.sics.cooja; @@ -314,8 +314,27 @@ public class Simulation extends Observable implements Runnable { } } + /** + * Stops simulation and conditionally blocks until stopped. + * + * @param block Blocks if true + * + * @see #stopSimulation() + */ + public void stopSimulation(boolean block) { + if (!isRunning()) { + return; + } + if (block) { + stopSimulation(); + } else { + stopSimulation = true; + } + } + /** * Stops this simulation (notifies observers). + * Method blocks until simulation has stopped. */ public void stopSimulation() { if (isRunning()) {