Public Member Functions | |
SimulationMaster () | |
synchronized void | startThread () |
synchronized void | stopThread () |
void | jumpToTime (int time) |
void | setTargetStepTime (int time) |
void | doOneStep () |
WorkerThread[] | createWorkers (int timePerStep, int threads) |
void | run () |
boolean | isSimulationRunning () |
boolean | isGuiEnabled () |
void | setGuiEnabled (boolean guiEnabled) |
Static Public Member Functions | |
static void | writeAnyTextToFile (String anyText, String fileName, boolean append) |
static boolean | isLogPerformance_ () |
static long | getStartTime () |
static void | setStartTime (long theStartTime) |
Static Public Attributes | |
static final int | TIME_PER_STEP = 40 |
This thread delegates the simulation processing to subthreads and then calls a repaint on the drawing area.
|
inline |
Instantiates a new simulation master.
|
inline |
Function to set up the worker threads with their corresponding regions. Each thread gets an equal amount of regions (some might get one more because of rounding). The amount of items in a region is not used as a method to improve equality between threads as this value might change over time (moving vehicles!). This function expects to get 2x the amount of CPU cores as threads so that the negative effects of an unequal allocation (some threads finishing faster as others => unused cpu power) are reduced.
timePerStep | the time per step in milliseconds |
threads | the amount of threads that shall be created |
|
inline |
Proceed one single step forward.
|
inline |
Returns if a simulation is currently running or not.
true
if a simulation is running, else false
|
inline |
Allows to jump to a specific time. While this mode is active, no display and statistics update is done.
time | the target time in milliseconds |
|
inline |
The main method for the simulation master initializes the worker threads, manages them and initiates the render process and statistics updates.
|
inline |
Sets the target step time. Decrease to get a faster simulation, increase to get a slower.
time |
|
inline |
Method to let this thread start delegating work to subthreads. Work in the main function is resumed, the subthreads (workers) will wake up again and the Renderer is notified to get active again.
|
inline |
Method to let this thread stop delegating work to subthreads. Work in the main function is suspended, the subthreads (workers) will go to sleep and the Renderer is notified to get inactive.
|
inlinestatic |
Writes any data to file
|
static |
How much time passes in one step (in milliseconds). 40ms results in a smooth animation with 25fps.