IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.

IG::Num::ParallelJobContainerBase Class Reference

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...

Inheritance diagram for IG::Num::ParallelJobContainerBase:
Collaboration diagram for IG::Num::ParallelJobContainerBase:

List of all members.

Public Member Functions

 ParallelJobContainerBase ()
 Constructs a new parallel data container.
void NotifyJobStarted ()
 Notifies this job data container that its job has started.
void NotifyJobFinished ()
 Notifies this job data container that its job has finished.
void NotifyJobAborted ()
 Notifies this job data container that its job has been aborted.
void WaitJobCompletion ()
 Waits for job completion.
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).
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 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.
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.

Static Public Attributes

static volatile int DefaultOutputLevel = -1
 Default output level for objects of this and derived types. Also used for classes derived from ParallelJobServerBase and ParallelJobDispatcherBase
static volatile bool DefaultIsTestMode = false
 Default value of the testmode flag. Also used for classes derived from ParallelJobServerBase and ParallelJobDispatcherBase

Protected Member Functions

virtual void RunOnStarted ()
 Called when 'started' notification is triggered (within the method NotifyJobStarted).
virtual void RunOnFinished ()
 Called when 'finished' notification is triggered (within the method NotifyJobFinished).
virtual void RunOnAborted ()
 Called when 'aborted' notification is triggered (within the method NotifyJobAborted).
internal void AssignToDispatcher (ParallelJobDispatcherBase dispatcher)
 Assigns the current job to the specified dispatcher. This method is called in dispatcher's SendJob method.

Static Protected Member Functions

static int GetNextId ()
 Returns another ID that is unique for objects of the containing class its and derived classes.

Protected Attributes

ParallelJobState _state = ParallelJobState.Uninitialized
int _dispatcherJobId = -1
int _clientJobId = -1
object _clientData
int _sleepTimeMs = DefaultSleepTimeMs
ParallelJobDispatcherBase _dispatcher
int _outputLevel = DefaultOutputLevel
 Output level for objects of this class. Specifies how much output is printed to console during operation.
bool _isTestMode = DefaultIsTestMode
volatile int _numTestDelays = 1
double _testDelayInSeconds = 1.0
double _testDelayRelativeError = 0.0
ParallelJobCallback _onStarted = null
ParallelJobCallback _onFinished = null
ParallelJobCallback _onAborted = null

Properties

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.
ParallelJobState State [get, set]
 State of the parallel job whose data is contained in the current object.
bool IsJobCompleted [get]
 Flag indicating whether a job has finished. Flag is undefined (exception thrown) if state is earlier than ParallelJobState.DataReady or it equals to or is later than ParallelJobState.ResultsProcessed.
static object LockId [get]
 Lock used for acquiring IDs.
virtual int Id [get]
 Unique ID for objects of the currnet and derived classes.
int DispatcherJobId [get, set]
 Dispatcher's Id of the job contained in the current job data container. Id is normally assigned by the dispatcher.
int ClientJobId [get, set]
 Client's Id of the job contained in the current job data container. Assigned (or not) by the client.
object ClientData [get, set]
 Client's data for the job contained in the current job data container. Assigned (or not) by the client who creates and sends this job.
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.
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. DefaultSleepTimeMs specifies the default value that is set when object is created.
int OutputLevel [get, set]
 Output level for the current object. Specifies how much output is printed to console during operation.
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.
int NumTestDelays [get, set]
 Number of time intervals into which the total delay interval (property TestDelayInSeconds) is divided.
double TestDelayInSeconds [get, set]
 Delay time in the testing mode (in seconds), which is caused by calling sleep for the Thread.Sleep method.
double TestDelayRelativeError [get, set]
 Interval of random errors added to the test delay time, relative to unnoisy delay time.
int TestDelaySingleMs [get]
 Single test delay interval in milliseconds.
ParallelJobCallback OnStarted [get, set]
 Delegate that is executed on started event. When executing, job container is locked.
ParallelJobCallback OnFinished [get, set]
 Delegate that is executed on started event. When executing, job container is locked.
ParallelJobCallback OnAborted [get, set]
 Delegate that is executed on started event. When executing, job container is locked.

Private Attributes

object _mainLock = new object()
int _id = GetNextId()

Static Private Attributes

static object _lockId
static int _nextId = 0
static int _defaultSleepTimeMs = 5

Detailed Description

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;


Constructor & Destructor Documentation

IG::Num::ParallelJobContainerBase::ParallelJobContainerBase ( ) [inline]

Constructs a new parallel data container.


Member Function Documentation

static int IG::Num::ParallelJobContainerBase::GetNextId ( ) [inline, static, protected]

Returns another ID that is unique for objects of the containing class its and derived classes.

virtual void IG::Num::ParallelJobContainerBase::RunOnStarted ( ) [inline, protected, virtual]

Called when 'started' notification is triggered (within the method NotifyJobStarted).

Reimplemented in IG::Num::ParallelJobContainerGen< InputType, ResultType >.

virtual void IG::Num::ParallelJobContainerBase::RunOnFinished ( ) [inline, protected, virtual]

Called when 'finished' notification is triggered (within the method NotifyJobFinished).

Reimplemented in IG::Num::ParallelJobContainerGen< InputType, ResultType >.

virtual void IG::Num::ParallelJobContainerBase::RunOnAborted ( ) [inline, protected, virtual]

Called when 'aborted' notification is triggered (within the method NotifyJobAborted).

Reimplemented in IG::Num::ParallelJobContainerGen< InputType, ResultType >.

void IG::Num::ParallelJobContainerBase::NotifyJobStarted ( ) [inline]

Notifies this job data container that its job has started.

void IG::Num::ParallelJobContainerBase::NotifyJobFinished ( ) [inline]

Notifies this job data container that its job has finished.

void IG::Num::ParallelJobContainerBase::NotifyJobAborted ( ) [inline]

Notifies this job data container that its job has been aborted.

internal void IG::Num::ParallelJobContainerBase::AssignToDispatcher ( ParallelJobDispatcherBase  dispatcher) [inline, protected]

Assigns the current job to the specified dispatcher. This method is called in dispatcher's SendJob method.

Parameters:
dispatcher
void IG::Num::ParallelJobContainerBase::WaitJobCompletion ( ) [inline]

Waits for job completion.

bool IG::Num::ParallelJobContainerBase::WaitJobCompletion ( double  timeoutInSeconds) [inline]

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).

Parameters:
timeoutInSecondsTimeot in seconds.
Returns:
A flag indicating whether the job was actually completed when the function returned. If false is returned then timeout occurred.
override string IG::Num::ParallelJobContainerBase::ToString ( ) [inline]

Returns a string representation of the current job dispatcher, which contains relevent data about the server state.

Reimplemented in IG::Lib::CommandLineJobContainer, and IG::Num::ParallelJobContainerGen< InputType, ResultType >.

static void IG::Num::ParallelJobContainerBase::TestPerformance ( int  numPoints,
int  numServers,
int  maxEnqueued,
double  delayTimeSeconds,
double  delayTimeRelativeError,
int  sleepTimeMs,
int  clientOutputLevel 
) [inline, static]

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.

Parameters:
fromLower bount of the interval on which function is evaluated.
toUpper bound of teh interval on which function is evaluated.
numPointsNumber of equidistand points in which function is evaluated.
evaluationFunctionDelegate that is used to evaluate functions.
numServersNumber of servers to be used.
maxEnqueuedMaximal allowed number of jobs enquied.
delayTimeSecondsDelay tie iin seconds.
delayTimeRelativeError
clientOutputLevelLevel of output on dispatching activity within the method.
Returns:
Array of calculated results.
Parameters:
sleepTimeMsSleeping time for server threads.
static void IG::Num::ParallelJobContainerBase::TestPerformance ( double  from,
double  to,
int  numPoints,
SimpleFunctionDelegate< double, double >  evaluationFunction,
int  numServers,
int  maxEnqueued,
double  delayTimeSeconds,
double  delayTimeRelativeError,
int  sleepTimeMs,
int  clientOutputLevel 
) [inline, static]

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.

Parameters:
fromLower bount of the interval on which function is evaluated.
toUpper bound of teh interval on which function is evaluated.
numPointsNumber of equidistand points in which function is evaluated.
evaluationFunctionDelegate that is used to evaluate functions.
numServersNumber of servers to be used.
maxEnqueuedMaximal allowed number of jobs enquied.
delayTimeSecondsDelay tie iin seconds.
delayTimeRelativeError
clientOutputLevelLevel of output on dispatching activity within the method.
Returns:
Array of calculated results.
Parameters:
sleepTimeMsSleeping time for server threads.

Member Data Documentation

object IG::Num::ParallelJobContainerBase::_mainLock = new object() [private]
ParallelJobState IG::Num::ParallelJobContainerBase::_state = ParallelJobState.Uninitialized [protected]
int IG::Num::ParallelJobContainerBase::_nextId = 0 [static, private]
int IG::Num::ParallelJobContainerBase::_id = GetNextId() [private]
int IG::Num::ParallelJobContainerBase::_sleepTimeMs = DefaultSleepTimeMs [protected]

Default output level for objects of this and derived types. Also used for classes derived from ParallelJobServerBase and ParallelJobDispatcherBase

Output level for objects of this class. Specifies how much output is printed to console during operation.

Default value of the testmode flag. Also used for classes derived from ParallelJobServerBase and ParallelJobDispatcherBase

ParallelJobCallback IG::Num::ParallelJobContainerBase::_onStarted = null [protected]
ParallelJobCallback IG::Num::ParallelJobContainerBase::_onFinished = null [protected]
ParallelJobCallback IG::Num::ParallelJobContainerBase::_onAborted = null [protected]

Property Documentation

object IG::Num::ParallelJobContainerBase::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.

Implements IG::Lib::ILockable.

ParallelJobState IG::Num::ParallelJobContainerBase::State [get, set]

State of the parallel job whose data is contained in the current object.

bool IG::Num::ParallelJobContainerBase::IsJobCompleted [get]

Flag indicating whether a job has finished. Flag is undefined (exception thrown) if state is earlier than ParallelJobState.DataReady or it equals to or is later than ParallelJobState.ResultsProcessed.

object IG::Num::ParallelJobContainerBase::LockId [static, get]

Lock used for acquiring IDs.

virtual int IG::Num::ParallelJobContainerBase::Id [get]

Unique ID for objects of the currnet and derived classes.

Implements IG::Lib::IIdentifiable.

Reimplemented in IG::Lib::CommandLineJobContainer.

int IG::Num::ParallelJobContainerBase::DispatcherJobId [get, set]

Dispatcher's Id of the job contained in the current job data container. Id is normally assigned by the dispatcher.

int IG::Num::ParallelJobContainerBase::ClientJobId [get, set]

Client's Id of the job contained in the current job data container. Assigned (or not) by the client.

object IG::Num::ParallelJobContainerBase::ClientData [get, set]

Client's data for the job contained in the current job data container. Assigned (or not) by the client who creates and sends this job.

This can be used to help the client determine how to treat results when finished.

int IG::Num::ParallelJobContainerBase::DefaultSleepTimeMs [static, 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.

int IG::Num::ParallelJobContainerBase::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. DefaultSleepTimeMs specifies the default value that is set when object is created.

int IG::Num::ParallelJobContainerBase::OutputLevel [get, set]

Output level for the current object. Specifies how much output is printed to console during operation.

bool IG::Num::ParallelJobContainerBase::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.

int IG::Num::ParallelJobContainerBase::NumTestDelays [get, set]

Number of time intervals into which the total delay interval (property TestDelayInSeconds) is divided.

double IG::Num::ParallelJobContainerBase::TestDelayInSeconds [get, set]

Delay time in the testing mode (in seconds), which is caused by calling sleep for the Thread.Sleep method.

double IG::Num::ParallelJobContainerBase::TestDelayRelativeError [get, set]

Interval of random errors added to the test delay time, relative to unnoisy delay time.

int IG::Num::ParallelJobContainerBase::TestDelaySingleMs [get, protected]

Single test delay interval in milliseconds.

ParallelJobCallback IG::Num::ParallelJobContainerBase::OnStarted [get, set]

Delegate that is executed on started event. When executing, job container is locked.

ParallelJobCallback IG::Num::ParallelJobContainerBase::OnFinished [get, set]

Delegate that is executed on started event. When executing, job container is locked.

ParallelJobCallback IG::Num::ParallelJobContainerBase::OnAborted [get, set]

Delegate that is executed on started event. When executing, job container is locked.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties Events