de.cau.cs.kieler.sim.kiem.execution
Class ProducerExecution

java.lang.Object
  extended by de.cau.cs.kieler.sim.kiem.execution.ProducerExecution
All Implemented Interfaces:
Runnable

public class ProducerExecution
extends Object
implements Runnable

The Class ProducerExecution. This implements the behavior of a producer worker thread that operates on one dedicated DataComponenet that is a pure producer.

A producer needs no input data and hence is called in the beginning of a step so that it has the maximum time to concurrently compute its results.

If a blockingStep() is scheduled then the producer worker thread is awaked and can start to compute data. When the method blockingWaitUntilDone() is called, then this blocks until the data is computed.
Note that this could also trigger a time out in the execution thread.

Rating proposed yellow
(2009-01-15)

Constructor Summary
ProducerExecution(AbstractDataComponent dataComponentParam, Execution parentParam)
          Instantiates a new producer execution worker thread.
 
Method Summary
 void blockingStep()
          Schedule a (blocking) step.
 void blockingWaitUntilDone()
          Blocking wait until done.
 JSONObject getData()
          Gets the JSON data that was produced by the producer DataComponent.
 void run()
          When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.
 void stopExecution()
          Terminates the execution of this thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProducerExecution

public ProducerExecution(AbstractDataComponent dataComponentParam,
                         Execution parentParam)
Instantiates a new producer execution worker thread.

Parameters:
dataComponentParam - the affected DataComponent
parentParam - the parent execution
Method Detail

blockingStep

public void blockingStep()
Schedule a (blocking) step. This will awake the execution (blockingWaitUntilDone()) AND the waiting producer thread but only the producer thread will proceed, cause done is guaranteed to be false!
The execution will fall asleep until the producer has finished doing its step.


blockingWaitUntilDone

public void blockingWaitUntilDone()
Blocking wait until done. This method resumes only if the producer DataComponent is done (and sleeping again).


getData

public JSONObject getData()
Gets the JSON data that was produced by the producer DataComponent.

Returns:
the produced data

stopExecution

public void stopExecution()
Terminates the execution of this thread.


run

public void run()
When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

Specified by:
run in interface Runnable