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

- Main Page
- Namespaces
- Classes
- Files
- Directories

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Properties | Private Attributes | Static Private Attributes

# IG::Num::ParallelJobServerBase< JobContainerType > Class Template Reference

Parallel job server. Waits for job requests and executes them in a parallel thread. More...

Inheritance diagram for IG::Num::ParallelJobServerBase< JobContainerType >:
[legend]
Collaboration diagram for IG::Num::ParallelJobServerBase< JobContainerType >:
[legend]

List of all members.

## Public Member Functions
| ParallelJobServerBase ()
void | NotifyJobStarted ()
| Notifies all interested objects that the job has started.
void | NotifyJobFinished ()
| Notifies all interested objects that the job has finished.
void | NotifyJobAborted ()
| Notifies all interested parties that job has been aborted.
void | NotifyServerIdle (ParallelJobDispatcherBase< JobContainerType > dispatcher)
| Sets the Idle flag to true and notifies the containing dispatcher that the current server object has became idle.
void | StopServerThread ()
| Sends to the server thread command that it has to stop.
void | KillServerThread ()
| Forces the working to stop, even if it is in the middle of eecution of a job, by aborting the thread. To let the working thread finish its current jobs and then stop, call StopServerThread
void | StartServer ()
void | StartJobByServer ()
| Starts job by the server.
void | StartSingleJob ()
| Starts a single job in a new therad taht is created for this purpose.
void | RunJobSynchronous (JobContainerType jobData)
void | StartJob (JobContainerType jobData)
| Starts the current job in the way specified by internal flags.
override string | ToString ()
| Returns a string representation of the current job server, which contains relevent data about the server state.
## Protected Member Functions
void | NotifyServerAboutJob ()
void | Serve ()
abstract void | RunJobDefined (JobContainerType jobData)
| Runs the job.
void | RunSingleJobInThread ()
| Methods that runs the job on the serving thread, for the case when a new thread is allocated for each job (single job per thread).
void | RunJobInThread ()
| Methods that runs the job on the serving thread, for the case when server thread executes multiple jobs (server mode).
## 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
volatile bool | _isTestMode = ParallelJobContainerBase.DefaultIsTestMode
int | _sleepTimeMs = DefaultSleepTimeMs
ParallelJobDispatcherBase < JobContainerType > | _dispatcher
ParallelServerState | _state = ParallelServerState.Idle
JobContainerType | _jobData
bool | _isServer = false
bool | _commandStopServing = false
ThreadPriority | _threadPriority = UtilSystem.ThreadPriority
Thread | _workingThread
bool | _isServerRunning = false
## 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.
static int | DefaultOutputLevel`[get, set]`
| Default output level for objects of this and derived types. Just aliases the ParallelJobContainerBase.DefaultOutputLevel.
int | OutputLevel`[get, set]`
| Output level the current object. Specifies how much output is printed to console during operation.
static bool | DefaultIsTestMode`[get, set]`
| Default value of test mode flag. Just aliases the ParallelJobContainerBase.DefaultOutputLevel.
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 | Id`[get]`
| Unique ID for objects of the currnet and derived classes.
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.
ParallelJobDispatcherBase < JobContainerType > | Dispatcher`[get, set]`
ParallelServerState | State`[get, set]`
| Gets the state of the current job runner.
bool | IsIdle`[get]`
| Gets a flag indicating whether the current job runner is idle.
bool | IsActive`[get]`
JobContainerType | JobData`[get, set]`
| Data for the job that is executed by teh current parallel job runner.
bool | IsServer`[get, set]`
| Indicating whether the current job runner work as server. <par>If true then a server is started in a parallel thread that continuously for signals to start jobs.</par> If false then a new thread is started each time a job is run, and is deleted when a job finishes.
bool | CommandStopServing`[get, set]`
| Flag indicating whether the server should be stopped. If set to true and server thread is runing, then the server thread stops when the currently run job completes (or stops immediately if there is no job running).
ThreadPriority | ThreadPriority`[get, set]`
| Priority of the server thread. Setting priority changes priority of the server thread if it exists.
bool | IsServerRunning`[get]`
| Indicates whether the server is currently running or not.
bool | DoRunJobByServer`[get, set]`
## Private Attributes
object | _mainLock = new object()
volatile int | _outputLevel = ParallelJobContainerBase.DefaultOutputLevel
| Output level for objects of this class. Specifies how much output is printed to console during operation.
int | _id = GetNextId()
bool | _doRunJobByServer = false
## Static Private Attributes
static int | _nextId = 0
static int | _defaultSleepTimeMs = 2

## Detailed Description

### template<JobContainerType>
class IG::Num::ParallelJobServerBase< JobContainerType >

Parallel job server. Waits for job requests and executes them in a parallel thread.

Template Parameters:

  JobContainerType | Type of the container that holds data for the job (input and output).

///

The server executes jobs on a separate thread that is spawned by the server and is used just for this purpose.

The server object can operate in two modes. In the server mode, a server threas is started that continuously waits for job requests and executes them as soon as they arrive. In single job state, a new thread is started for each job request and is terminated when the job is completed.

Job request is sent by the

$A Igor Aug08;

Type Constraints

  JobContainerType | : | ParallelJobContainerBase |

## Member Function Documentation

template<JobContainerType >

IG::Num::ParallelJobServerBase< JobContainerType >::ParallelJobServerBase | ( |  | ) | `[inline]`

template<JobContainerType >

static int IG::Num::ParallelJobServerBase< JobContainerType >::GetNextId | ( |  | ) | `[inline, static, protected]`

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

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::NotifyJobStarted | ( |  | ) | `[inline]`

Notifies all interested objects that the job has started.

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::NotifyJobFinished | ( |  | ) | `[inline]`

Notifies all interested objects that the job has finished.

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::NotifyJobAborted | ( |  | ) | `[inline]`

Notifies all interested parties that job has been aborted.

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::NotifyServerIdle | ( | ParallelJobDispatcherBase< JobContainerType > | dispatcher | ) | `[inline]`

Sets the Idle flag to true and notifies the containing dispatcher that the current server object has became idle.

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::StopServerThread | ( |  | ) | `[inline]`

Sends to the server thread command that it has to stop.

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::KillServerThread | ( |  | ) | `[inline]`

Forces the working to stop, even if it is in the middle of eecution of a job, by aborting the thread. To let the working thread finish its current jobs and then stop, call StopServerThread

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::NotifyServerAboutJob | ( |  | ) | `[inline, protected]`

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::Serve | ( |  | ) | `[inline, protected]`

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::StartServer | ( |  | ) | `[inline]`

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::StartJobByServer | ( |  | ) | `[inline]`

Starts job by the server.

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::StartSingleJob | ( |  | ) | `[inline]`

Starts a single job in a new therad taht is created for this purpose.

template<JobContainerType >

abstract void IG::Num::ParallelJobServerBase< JobContainerType >::RunJobDefined | ( | JobContainerType | jobData | ) | `[protected, pure virtual]`

Runs the job.

Parameters:

  jobData | Data container for the job to be run.

Implemented in IG::Num::ParallelJobServerGen< InputType, ResultType, JobContainerType >.

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::RunSingleJobInThread | ( |  | ) | `[inline, protected]`

Methods that runs the job on the serving thread, for the case when a new thread is allocated for each job (single job per thread).

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::RunJobInThread | ( |  | ) | `[inline, protected]`

Methods that runs the job on the serving thread, for the case when server thread executes multiple jobs (server mode).

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::RunJobSynchronous | ( | JobContainerType | jobData | ) | `[inline]`

template<JobContainerType >

void IG::Num::ParallelJobServerBase< JobContainerType >::StartJob | ( | JobContainerType | jobData | ) | `[inline]`

Starts the current job in the way specified by internal flags.

If the IsServer flag is true then job is started by notifying the continuously running server thread to run the job. Server thread is created and started if necessary. If the flag is false then a new thread is started to run the job and the thread exits when the job is run.

template<JobContainerType >

override string IG::Num::ParallelJobServerBase< JobContainerType >::ToString | ( |  | ) | `[inline]`

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

## Member Data Documentation

template<JobContainerType >

object IG::Num::ParallelJobServerBase< JobContainerType >::_mainLock = new object()`[private]`

template<JobContainerType >

volatile int IG::Num::ParallelJobServerBase< JobContainerType >::_outputLevel = ParallelJobContainerBase.DefaultOutputLevel`[private]`

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

template<JobContainerType >

volatile bool IG::Num::ParallelJobServerBase< JobContainerType >::_isTestMode = ParallelJobContainerBase.DefaultIsTestMode`[protected]`

template<JobContainerType >

int IG::Num::ParallelJobServerBase< JobContainerType >::_nextId = 0`[static, private]`

template<JobContainerType >

int IG::Num::ParallelJobServerBase< JobContainerType >::_id = GetNextId()`[private]`

template<JobContainerType >

int IG::Num::ParallelJobServerBase< JobContainerType >::_defaultSleepTimeMs = 2`[static, private]`

template<JobContainerType >

int IG::Num::ParallelJobServerBase< JobContainerType >::_sleepTimeMs = DefaultSleepTimeMs`[protected]`

template<JobContainerType >

ParallelJobDispatcherBase<JobContainerType> IG::Num::ParallelJobServerBase< JobContainerType >::_dispatcher`[protected]`

template<JobContainerType >

ParallelServerState IG::Num::ParallelJobServerBase< JobContainerType >::_state = ParallelServerState.Idle`[protected]`

template<JobContainerType >

JobContainerType IG::Num::ParallelJobServerBase< JobContainerType >::_jobData`[protected]`

template<JobContainerType >

bool IG::Num::ParallelJobServerBase< JobContainerType >::_isServer = false`[protected]`

template<JobContainerType >

bool IG::Num::ParallelJobServerBase< JobContainerType >::_commandStopServing = false`[protected]`

template<JobContainerType >

ThreadPriority IG::Num::ParallelJobServerBase< JobContainerType >::_threadPriority = UtilSystem.ThreadPriority`[protected]`

template<JobContainerType >

Thread IG::Num::ParallelJobServerBase< JobContainerType >::_workingThread`[protected]`

template<JobContainerType >

bool IG::Num::ParallelJobServerBase< JobContainerType >::_isServerRunning = false`[protected]`

template<JobContainerType >

bool IG::Num::ParallelJobServerBase< JobContainerType >::_doRunJobByServer = false`[private]`

## Property Documentation

template<JobContainerType >

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

template<JobContainerType >

int IG::Num::ParallelJobServerBase< JobContainerType >::DefaultOutputLevel`[static, get, set]`

Default output level for objects of this and derived types. Just aliases the ParallelJobContainerBase.DefaultOutputLevel.

template<JobContainerType >

int IG::Num::ParallelJobServerBase< JobContainerType >::OutputLevel`[get, set]`

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

template<JobContainerType >

bool IG::Num::ParallelJobServerBase< JobContainerType >::DefaultIsTestMode`[static, get, set]`

Default value of test mode flag. Just aliases the ParallelJobContainerBase.DefaultOutputLevel.

template<JobContainerType >

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

template<JobContainerType >

int IG::Num::ParallelJobServerBase< JobContainerType >::Id`[get]`

Unique ID for objects of the currnet and derived classes.

Implements IG::Lib::IIdentifiable.

template<JobContainerType >

int IG::Num::ParallelJobServerBase< JobContainerType >::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.

template<JobContainerType >

int IG::Num::ParallelJobServerBase< JobContainerType >::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.

template<JobContainerType >

ParallelJobDispatcherBase<JobContainerType> IG::Num::ParallelJobServerBase< JobContainerType >::Dispatcher`[get, set]`

template<JobContainerType >

ParallelServerState IG::Num::ParallelJobServerBase< JobContainerType >::State`[get, set]`

Gets the state of the current job runner.

template<JobContainerType >

bool IG::Num::ParallelJobServerBase< JobContainerType >::IsIdle`[get]`

Gets a flag indicating whether the current job runner is idle.

template<JobContainerType >

bool IG::Num::ParallelJobServerBase< JobContainerType >::IsActive`[get]`

template<JobContainerType >

JobContainerType IG::Num::ParallelJobServerBase< JobContainerType >::JobData`[get, set, private]`

Data for the job that is executed by teh current parallel job runner.

template<JobContainerType >

bool IG::Num::ParallelJobServerBase< JobContainerType >::IsServer`[get, set]`

Indicating whether the current job runner work as server. <par>If true then a server is started in a parallel thread that continuously for signals to start jobs.</par> If false then a new thread is started each time a job is run, and is deleted when a job finishes.

template<JobContainerType >

bool IG::Num::ParallelJobServerBase< JobContainerType >::CommandStopServing`[get, set]`

Flag indicating whether the server should be stopped. If set to true and server thread is runing, then the server thread stops when the currently run job completes (or stops immediately if there is no job running).

template<JobContainerType >

ThreadPriority IG::Num::ParallelJobServerBase< JobContainerType >::ThreadPriority`[get, set]`

Priority of the server thread. Setting priority changes priority of the server thread if it exists.

template<JobContainerType >

bool IG::Num::ParallelJobServerBase< JobContainerType >::IsServerRunning`[get]`

Indicates whether the server is currently running or not.

template<JobContainerType >

bool IG::Num::ParallelJobServerBase< JobContainerType >::DoRunJobByServer`[get, set]`

The documentation for this class was generated from the following file:

- ParallelJobServerBase.cs

All Classes Namespaces Files Functions Variables Enumerations Properties Events