IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.
|
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. More...
Public Member Functions | |
ParallelJobContainerGen () | |
Creates a new parallel job container. | |
ParallelJobContainerGen (SimpleFunctionDelegate< InputType, ResultType > evaluationDelegate) | |
Creates a new parallel job container with inptu data assigned. | |
ParallelJobContainerGen (SimpleFunctionDelegate< InputType, ResultType > evaluationDelegate, InputType inputData) | |
Creates a new parallel job container with inptu data assigned. | |
ParallelJobContainerGen (SimpleFunctionDelegate< InputType, ResultType > evaluationDelegate, InputType inputData, object clientData) | |
Creates a new parallel job container with inptu data assigned. | |
virtual void | RunJob () |
Performs the job by the data contained in the current job container. Warning: only works when the IsJobDefined flag is true. | |
ResultType | RunJob (InputType input) |
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. | |
override string | ToString () |
Returns a string representation of the current job dispatcher, which contains relevent data about the server state. | |
Static Public Member Functions | |
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. | |
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). | |
static ParallelJobServerGen < InputType, ResultType > | CreateServer () |
Creates and returns a new job server for the current job container type. | |
static ParallelJobServerGen < InputType, ResultType > | CreateServer (int sleeptimeMs) |
Creates and returns a new job server for the current job container type. | |
static ParallelJobContainerGen < InputType, ResultType > | CreateJobContainer () |
Creates and returns a new job container of the current type. | |
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. | |
Protected Member Functions | |
override void | RunOnStarted () |
Called when 'started' notification is triggered (within the method NotifyJobStarted). | |
override void | RunOnFinished () |
Called when 'finished' notification is triggered (within the method NotifyJobFinished). | |
override void | RunOnAborted () |
Called when 'aborted' notification is triggered (within the method NotifyJobAborted). | |
virtual internal ResultType | CalculateResultsPlain (InputType input) |
Calculates and returns results from the specified input data. | |
Protected Attributes | |
InputType | _input |
ResultType | _result |
ParallelJobCallbackGen < InputType, ResultType > | _onStartedGeneric = null |
ParallelJobCallbackGen < InputType, ResultType > | _onFinishedGeneric = null |
ParallelJobCallbackGen < InputType, ResultType > | _onAbortedGeneric = null |
SimpleFunctionDelegate < InputType, ResultType > | _evaluationDelegate = null |
bool | _doesNotContainJobDefinition = false |
Properties | |
InputType | Input [get, set] |
Input for the current job. | |
ResultType | Result [get, set] |
Result of the current job. | |
ParallelJobCallbackGen < InputType, ResultType > | OnStartedGeneric [get, set] |
Delegate that is executed on started event. When executing, job container is locked. | |
ParallelJobCallbackGen < InputType, ResultType > | OnFinishedGeneric [get, set] |
Delegate that is executed on started event. When executing, job container is locked. | |
ParallelJobCallbackGen < InputType, ResultType > | OnAbortedGeneric [get, set] |
Delegate that is executed on started event. When executing, job container is locked. | |
SimpleFunctionDelegate < InputType, ResultType > | EvaluationDelegate [get, set] |
Evaluation delegate that is by default used for calculation of results from input data of the parallel job. | |
virtual bool | IsJobDefined [get, set] |
Indicates whether the curren job container can itself execute a job by calling either variant of the RunJob method. |
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;
IG::Num::ParallelJobContainerGen< InputType, ResultType >::ParallelJobContainerGen | ( | ) | [inline] |
Creates a new parallel job container.
IG::Num::ParallelJobContainerGen< InputType, ResultType >::ParallelJobContainerGen | ( | SimpleFunctionDelegate< InputType, ResultType > | evaluationDelegate | ) | [inline] |
Creates a new parallel job container with inptu data assigned.
evaluationDelegate | Dellegate that performs calculation. |
IG::Num::ParallelJobContainerGen< InputType, ResultType >::ParallelJobContainerGen | ( | SimpleFunctionDelegate< InputType, ResultType > | evaluationDelegate, |
InputType | inputData | ||
) | [inline] |
Creates a new parallel job container with inptu data assigned.
EvaluationDelegate | Dellegate that performs calculation. |
inputData | Inpt data for the job. |
IG::Num::ParallelJobContainerGen< InputType, ResultType >::ParallelJobContainerGen | ( | SimpleFunctionDelegate< InputType, ResultType > | evaluationDelegate, |
InputType | inputData, | ||
object | clientData | ||
) | [inline] |
Creates a new parallel job container with inptu data assigned.
EvaluationDelegate | Dellegate that performs calculation. |
inputData | Inpt data for the job. |
override void IG::Num::ParallelJobContainerGen< InputType, ResultType >::RunOnStarted | ( | ) | [inline, protected, virtual] |
Called when 'started' notification is triggered (within the method NotifyJobStarted).
Reimplemented from IG::Num::ParallelJobContainerBase.
override void IG::Num::ParallelJobContainerGen< InputType, ResultType >::RunOnFinished | ( | ) | [inline, protected, virtual] |
Called when 'finished' notification is triggered (within the method NotifyJobFinished).
Reimplemented from IG::Num::ParallelJobContainerBase.
override void IG::Num::ParallelJobContainerGen< InputType, ResultType >::RunOnAborted | ( | ) | [inline, protected, virtual] |
Called when 'aborted' notification is triggered (within the method NotifyJobAborted).
Reimplemented from IG::Num::ParallelJobContainerBase.
virtual internal ResultType IG::Num::ParallelJobContainerGen< InputType, ResultType >::CalculateResultsPlain | ( | InputType | input | ) | [inline, protected, virtual] |
Calculates and returns results from the specified input data.
input | Input for calculation. |
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).
The parallel job can be executed on the current job container by the RunJob method. That method in turn calls this method, and by overriding the method one can modify how job execution is performed.
The basic variant defined in the ParallelJobContainerGen class just calls the EvaluationDelegate delegate to perform the job, or throws exception if the delegate is not assigned. This behavior can be chabged by overriding the method.
virtual void IG::Num::ParallelJobContainerGen< InputType, ResultType >::RunJob | ( | ) | [inline, virtual] |
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.
input | Input data for the job that is executed when calling this function. |
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.
static ParallelJobDispatcherGen<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::CreateDispatcher | ( | int | numServers | ) | [inline, static] |
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.
numServers | Number of servers created and added to the created dispatcher. |
static ParallelJobDispatcherGen<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::CreateDispatcher | ( | int | numServers, |
int | sleepTimeMs | ||
) | [inline, static] |
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).
numServers | Number of servers created and added to the created dispatcher. |
sleepTimeMs | Sleeping time (in milliseconds) for dospatcher's server thread and for servers' threads. |
static ParallelJobServerGen<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::CreateServer | ( | ) | [inline, static] |
Creates and returns a new job server for the current job container type.
static ParallelJobServerGen<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::CreateServer | ( | int | sleeptimeMs | ) | [inline, static] |
Creates and returns a new job server for the current job container type.
sleeptimeMs | Sleeping time for the server's serving thread, in milliseconds. |
static ParallelJobContainerGen<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::CreateJobContainer | ( | ) | [inline, static] |
Creates and returns a new job container of the current type.
static ResultType [] IG::Num::ParallelJobContainerGen< InputType, ResultType >::TestPerformance | ( | InputType[] | inputs, |
SimpleFunctionDelegate< InputType, ResultType > | evaluationFunction, | ||
int | numServers, | ||
int | maxEnqueued, | ||
double | delayTimeSeconds, | ||
double | delayTimeRelativeError, | ||
int | sleepTimeMs, | ||
int | clientOutputLevel | ||
) | [inline, static] |
Test of parallel job execution.
inputs | Array of job inputs. |
evaluationFunction | Delegate that is used to evaluate functions. |
numServers | Number of servers to be used. |
maxEnqueued | Maximal allowed number of jobs enquied. |
delayTimeSeconds | Delay tie iin seconds. |
delayTimeRelativeError | |
sleepTimeMs | Sleep time of server threads, in milliseconds. |
clientOutputLevel | Level of output on dispatching activity within the method. |
override string IG::Num::ParallelJobContainerGen< InputType, ResultType >::ToString | ( | ) | [inline] |
Returns a string representation of the current job dispatcher, which contains relevent data about the server state.
Reimplemented from IG::Num::ParallelJobContainerBase.
Reimplemented in IG::Lib::CommandLineJobContainer.
InputType IG::Num::ParallelJobContainerGen< InputType, ResultType >::_input [protected] |
ResultType IG::Num::ParallelJobContainerGen< InputType, ResultType >::_result [protected] |
ParallelJobCallbackGen<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::_onStartedGeneric = null [protected] |
ParallelJobCallbackGen<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::_onFinishedGeneric = null [protected] |
ParallelJobCallbackGen<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::_onAbortedGeneric = null [protected] |
SimpleFunctionDelegate<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::_evaluationDelegate = null [protected] |
bool IG::Num::ParallelJobContainerGen< InputType, ResultType >::_doesNotContainJobDefinition = false [protected] |
InputType IG::Num::ParallelJobContainerGen< InputType, ResultType >::Input [get, set] |
Input for the current job.
ResultType IG::Num::ParallelJobContainerGen< InputType, ResultType >::Result [get, set] |
Result of the current job.
ParallelJobCallbackGen<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::OnStartedGeneric [get, set] |
Delegate that is executed on started event. When executing, job container is locked.
ParallelJobCallbackGen<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::OnFinishedGeneric [get, set] |
Delegate that is executed on started event. When executing, job container is locked.
ParallelJobCallbackGen<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::OnAbortedGeneric [get, set] |
Delegate that is executed on started event. When executing, job container is locked.
SimpleFunctionDelegate<InputType, ResultType> IG::Num::ParallelJobContainerGen< InputType, ResultType >::EvaluationDelegate [get, set] |
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.
virtual bool IG::Num::ParallelJobContainerGen< InputType, ResultType >::IsJobDefined [get, set] |
Indicates whether the curren job container can itself execute a job by calling either variant of the RunJob method.
This flag must be consistent with the CalculateResultsPlain and RunJob methods. If any of these method is overridden, consistency must be preserved, which may require overriding the property, too.