General purpose parallel job container that contains methods for running the job in on the same machine thread. Contains many auxiliary methods for testing and for adaptation of parallel jobs concepts to different tasks.
More...
|
| ParallelJobContainerGen () |
| Creates a new parallel job container. More...
|
|
| ParallelJobContainerGen (SimpleFunctionDelegate< InputType, ResultType > evaluationDelegate) |
| Creates a new parallel job container with inptu data assigned. More...
|
|
| ParallelJobContainerGen (SimpleFunctionDelegate< InputType, ResultType > evaluationDelegate, InputType inputData) |
| Creates a new parallel job container with inptu data assigned. More...
|
|
| ParallelJobContainerGen (SimpleFunctionDelegate< InputType, ResultType > evaluationDelegate, InputType inputData, object clientData) |
| Creates a new parallel job container with inptu data assigned. More...
|
|
virtual void | RunJob () |
| Performs the job by the data contained in the current job container. More...
|
|
ResultType | RunJob (InputType input) |
| Calculates and results of the job corresponding to the current job container, based on the specified intput data. More...
|
|
override string | ToString () |
| Returns a string representation of the current job dispatcher, which contains relevent data about the server state. More...
|
|
| ParallelJobContainerBase () |
| Constructs a new parallel data container. More...
|
|
void | NotifyJobStarted () |
| Notifies this job data container that its job has started. More...
|
|
void | NotifyJobFinished () |
| Notifies this job data container that its job has finished. More...
|
|
void | NotifyJobAborted () |
| Notifies this job data container that its job has been aborted. More...
|
|
void | WaitJobCompletion () |
| Waits for job completion. More...
|
|
bool | WaitJobCompletion (double timeoutInSeconds) |
| Wait until the current job whose data is contained in this object completes, or timeout occurs (timeout specified in seconds), and returns a flag indicating whether the job has actually completed (i.e. stop was not due to timeout). More...
|
|
override string | ToString () |
| Returns a string representation of the current job dispatcher, which contains relevent data about the server state. More...
|
|
|
static
ParallelJobDispatcherGen
< InputType, ResultType > | CreateDispatcher (int numServers) |
| Creates and returns a parallel job dispatcher for job containers of the current typa, with the specified number of servers initialized and added on the dispatcher. More...
|
|
static
ParallelJobDispatcherGen
< InputType, ResultType > | CreateDispatcher (int numServers, int sleepTimeMs) |
| Creates and returns a parallel job dispatcher for job containers of the current typa, with the specified number of servers initialized and added on the dispatcher, and with specified sleeping time (used for the dispetcher and added servers). More...
|
|
static ParallelJobServerGen
< InputType, ResultType > | CreateServer () |
| Creates and returns a new job server for the current job container type. More...
|
|
static ParallelJobServerGen
< InputType, ResultType > | CreateServer (int sleeptimeMs) |
| Creates and returns a new job server for the current job container type. More...
|
|
static ParallelJobContainerGen
< InputType, ResultType > | CreateJobContainer () |
| Creates and returns a new job container of the current type. More...
|
|
static ResultType[] | TestPerformance (InputType[] inputs, SimpleFunctionDelegate< InputType, ResultType > evaluationFunction, int numServers, int maxEnqueued, double delayTimeSeconds, double delayTimeRelativeError, int sleepTimeMs, int clientOutputLevel) |
| Test of parallel job execution. More...
|
|
static void | TestPerformance (int numPoints, int numServers, int maxEnqueued, double delayTimeSeconds, double delayTimeRelativeError, int sleepTimeMs, int clientOutputLevel) |
| Test of parallel job execution by calculating the specified real function of one variable in a number of points. Calculatin is performed in parallel threads by using job dispatcher with parallel servers. More...
|
|
static void | TestPerformance (double from, double to, int numPoints, SimpleFunctionDelegate< double, double > evaluationFunction, int numServers, int maxEnqueued, double delayTimeSeconds, double delayTimeRelativeError, int sleepTimeMs, int clientOutputLevel) |
| Test of parallel job execution by calculating the specified real function of one variable in a number of points. Calculatin is performed in parallel threads by using job dispatcher with parallel servers. More...
|
|
|
InputType | Input [get, set] |
| Input for the current job. More...
|
|
ResultType | Result [get, set] |
| Result of the current job. More...
|
|
ParallelJobCallbackGen
< InputType, ResultType > | OnStartedGeneric [get, set] |
| Delegate that is executed on started event. More...
|
|
ParallelJobCallbackGen
< InputType, ResultType > | OnFinishedGeneric [get, set] |
| Delegate that is executed on started event. More...
|
|
ParallelJobCallbackGen
< InputType, ResultType > | OnAbortedGeneric [get, set] |
| Delegate that is executed on started event. More...
|
|
SimpleFunctionDelegate
< InputType, ResultType > | EvaluationDelegate [protected get, set] |
| Evaluation delegate that is by default used for calculation of results from input data of the parallel job. More...
|
|
virtual bool | IsJobDefined [get, set] |
| Indicates whether the curren job container can itself execute a job by calling either variant of the RunJob method. More...
|
|
object | Lock [get] |
| This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. More...
|
|
ParallelJobState | State [get, set] |
| State of the parallel job whose data is contained in the current object. More...
|
|
bool | IsJobCompleted [get] |
| Flag indicating whether a job has finished. More...
|
|
static object | LockId [get] |
| Lock used for acquiring IDs. More...
|
|
virtual int | Id [get] |
| Unique ID for objects of the currnet and derived classes. More...
|
|
int | DispatcherJobId [get, protected set] |
| Dispatcher's Id of the job contained in the current job data container. More...
|
|
int | ClientJobId [get, set] |
| Client's Id of the job contained in the current job data container. More...
|
|
object | ClientData [get, protected set] |
| Client's data for the job contained in the current job data container. More...
|
|
static int | DefaultSleepTimeMs [get, set] |
| Default sleeping time, in milliseconds, used by parallel job data objects when waiting for fulfillment of some condition in a loop that includes sleeping when condition is not met. More...
|
|
int | SleepTimeMs [get, set] |
| Sleeping time, in milliseconds, used by the current object when waiting for fulfillment of some condition in a loop that includes sleeping when condition is not met. More...
|
|
int | OutputLevel [get, set] |
| Output level for the current object. More...
|
|
bool | IsTestMode [get, set] |
| Whether the current job data conntainer is in test mode. In this mode, delays specified by internal variables are automatically added in job execution. More...
|
|
int | NumTestDelays [get, set] |
| Number of time intervals into which the total delay interval (property TestDelayInSeconds) is divided. More...
|
|
double | TestDelayInSeconds [get, set] |
| Delay time in the testing mode (in seconds), which is caused by calling sleep for the Thread.Sleep method. More...
|
|
double | TestDelayRelativeError [get, set] |
| Interval of random errors added to the test delay time, relative to unnoisy delay time. More...
|
|
int | TestDelaySingleMs [get] |
| Single test delay interval in milliseconds. More...
|
|
ParallelJobCallback | OnStarted [get, set] |
| Delegate that is executed on started event. More...
|
|
ParallelJobCallback | OnFinished [get, set] |
| Delegate that is executed on started event. More...
|
|
ParallelJobCallback | OnAborted [get, set] |
| Delegate that is executed on started event. More...
|
|
object | Lock [get] |
|
int | Id [get] |
| Returns unique ID (in the scope of a given type) of the current object. More...
|
|
General purpose parallel job container that contains methods for running the job in on the same machine thread. Contains many auxiliary methods for testing and for adaptation of parallel jobs concepts to different tasks.
Contains input data and results of a parallel job to be executed, oropertied indicating the state of the job, and methods for interaction with job performer and dispatcher.
This class interacts with parallel job dispatcher that sends a job to the specific server, and with the parallel server that executes the job.
$A Igor Aug08;
virtual void IG.Num.ParallelJobContainerGen< InputType, ResultType >.RunJob |
( |
| ) |
|
|
inlinevirtual |
Performs the job by the data contained in the current job container.
Warning: only works when the IsJobDefined flag is true.
Warning: This method should only be called if the flag is true. Otherwise, the job container itself does not know how to execute the job, an this must be done by the appropriate parallel job server object (base type ParallelJobServerBase).
When overriding this method, it must be checked that consistency with the IsJobDefined flag is preserved (one may also need to override the flag).
Parallel jobs by data contained job container objects are normally run by the job server objects that know how to execute teh job. Im this type of job containers, it can be defined by the job container how to run the job in a parallel thread, and this can be done by calling this method. This method can also be used by job servers to execute the job.
Calculation is performed by calling the CalculateResultsPlain method. In its original form, that method just calls the EvaluationDelegate delegate and throws exception if the delegate is not defined. The behavior can be changed either by overriding the CalculateResultsPlain method (recommendable) or by overriding this method (not recommended, but still left as choice).
ResultType IG.Num.ParallelJobContainerGen< InputType, ResultType >.RunJob |
( |
InputType |
input | ) |
|
|
inline |
Calculates and results of the job corresponding to the current job container, based on the specified intput data.
Calculation is performed by setting input data and calling the RunJob() method.
- Parameters
-
input | Input data for the job that is executed when calling this function. |
- Returns
- Results of execution of the job.
Warning: This method should only be called if the flag is true. Otherwise, the job container itself does not know how to execute the job, an this must be done by the appropriate parallel job server object (base type ParallelJobServerBase).
This function locks the current job container object's lock. It is therefore thread safe, but may not be called in the context where locking the job container could cause delays or deadlocks.
SimpleFunctionDelegate<InputType, ResultType> IG.Num.ParallelJobContainerGen< InputType, ResultType >.EvaluationDelegate |
|
protected getset |
Evaluation delegate that is by default used for calculation of results from input data of the parallel job.
This delegate can be specified by the user of the job container object in order to specify means of how job is performed. The delegate is called on input data in order to calculate and provide job results via returned value.
Normally, job is perfomed by the job server object that knows how to perfom the job. However, some job server objects will use this delegate in order toperform the job. The delegate should be accessed through calling the CalculateResultsPlain method.