@Override public final void run() { while (simulationRunning) { try { /* * The End of the Replanning is synchronized with * the TimeStepEndBarrier. If all Threads reach this Barrier * the main run() Thread can go on. * * The Threads wait now at the TimeStepStartBarrier until * they are triggered again in the next TimeStep by the main run() * method. */ timeStepEndBarrier.await(); timeStepStartBarrier.await(); if (!simulationRunning) { Gbl.printCurrentThreadCpuTime(); return; } doReplanning(); } catch (InterruptedException | BrokenBarrierException e) { throw new RuntimeException(e); } } // while Simulation Running } // run()
Gbl.printCurrentThreadCpuTime(); return;
@Override public Boolean call() { // implementing "call" and "run" side by side because it seems the easier way to // experimentally switch between the two types of threading. // kai, jan'14 // Check if Simulation is still running. Otherwise print CPU usage and end thread. if (!this.simulationRunning) { Gbl.printCurrentThreadCpuTime(); return false; } if (this.movingNodes) { moveNodes(); } else { moveLinks(); } return true ; }
@Override public void run() { try { // process events, until LastEventOfIteration arrives while (true) { // take waits for an element to exist before returning: // - thread sleeps until there is an event to process // - we do not have to bother checking if the element exists Event nextEvent = eventQueue.take(); if (nextEvent instanceof LastEventOfIteration) { Gbl.printCurrentThreadCpuTime(); // if there are more events generated after end of simulation // (generated in events handler), process them before stopping events handling. // in order to do this, LastEventOfIteration is moved to the back of the queue. if (eventQueue.size()>0){ processEvent(nextEvent); emptyPreBuffer(); nextEvent = eventQueue.take(); } else { return; } } getEvents().processEvent(nextEvent); } } catch ( InterruptedException e ) { throw new RuntimeException( e ); } }
throw new RuntimeException(e); Gbl.printCurrentThreadCpuTime();
Gbl.printCurrentThreadCpuTime(); return;
Gbl.printCurrentThreadCpuTime(); return;