IGLib
1.5
The IGLib base library for development of numerical, technical and business applications.
|
Parallel job dispatcher for job containers that inherit from ParallelJobContainerGen. More...
Public Member Functions | |
ParallelJobDispatcherGen () | |
![]() | |
ParallelJobDispatcherBase () | |
void | AddServer (ParallelJobServerBase< JobContainerType > server) |
Adds the specified server to the current dispatcher. More... | |
void | RemoveServer (ParallelJobServerBase< JobContainerType > server) |
Removes the specified server to the current dispatcher. More... | |
void | SetServersSleepTimeMs (int sleepTimeMs) |
Sets sleeping time in milliseconds on all servers assigned to the current parallel job dispatcher. More... | |
void | SetServersOutputLevel (int outputLevel) |
Sets output level on all servers assigned to the current parallel job dispatcher. More... | |
void | SetServersIsServer (bool isServer) |
Sets the server flag on all servers assigned to the current parallel job dispatcher. More... | |
bool | SendJob (JobContainerType jobData) |
Enqueues job for execution, and returns a flag indicating whether a job has been started immediately. More... | |
void | SendJob (JobContainerType jobData, out bool startedImmediately) |
Enqueues job for execution. More... | |
void | WaitAllJobsCompleted () |
Waits for job completion. More... | |
bool | WaitAllJobsCompleted (double timeoutInSeconds) |
Wait until all jobs that weer sent to the current dispatcher object complete, or timeout occurs (timeout specified in seconds), and returns a flag indicating whether the jobs have actually completed (i.e. stop was not due to timeout). More... | |
void | StopServer () |
Sends to the server thread command that it has to stop. More... | |
bool | StopServerWhenAllJobsDone () |
Waits until all jobs are completed, and then stops the server. More... | |
bool | StopServerWhenAllJobsDone (double timeoutInSeconds) |
Waits until all jobs are completed or timeout occurs, and then stops the server. Returns a flag indicating whether all jobs are actually completed before server was ordered to stop. More... | |
void | KillDispatcherThread () |
Forces the working thread to stop. To let the working thread finish its current jobs and then stop, call StopServer More... | |
void | KillServerThreads () |
Forces all the server threads to stop, even if in the middle of eecution of a job. To let the working thread finish its current jobs and then stop, call StopServer More... | |
void | KillThreads () |
Forces all the server threads to stop, even if in the middle of eecution of a job. To let the working thread finish its current jobs and then stop, call StopServer More... | |
void | RegisterSystemPriorityUpdating () |
Registers the UpdateThreadPriorityFromSystem method as "event handler" for system priority changes. After registration, this method will be called every time the value of the UtilSystem.ThreadPriority property changes. More... | |
void | UnregisterSystemPriorityUpdating () |
Unregisters the UpdateThreadPriorityFromSystem method as "event handler" for system priority changes. More... | |
void | StartServer () |
Starts the queue server. More... | |
void | NotifyJobStarted (ParallelJobServerBase< JobContainerType > server, JobContainerType job) |
Notifies the current dispatched that the specified job has started on the specified server. More... | |
void | NotifyJobFinished (ParallelJobServerBase< JobContainerType > server, JobContainerType job) |
Notifies the current dispatched that the specified job has started on the specified server. More... | |
void | NotifyJobAborted (ParallelJobServerBase< JobContainerType > server, JobContainerType job) |
Notifies the current dispatched that the specified job has started on the specified server. More... | |
void | NotifyServerIdle (ParallelJobServerBase< JobContainerType > server) |
Notifies the current parallel job dispatcher that the specified server has become idle. More... | |
override string | ToString () |
Returns a string representation of the current job dispatcher, which contains relevent data about the server state. More... | |
![]() | |
void | IncrementNumSentJobs () |
Increments by one the number of sent jobs (all jobs sent to the current dispatcher for execution). More... | |
void | IncrementNumStartedJobs () |
Increments by one the number of started by the dispatcher up to this point. More... | |
void | IncrementNumFinishedJobs () |
Increments by one the number of finished jobs (of those handled by the current dispatcher) up to this point. More... | |
void | IncrementNumAbortedJobs () |
Increments by one the number of aborted jobs (of those handled by the current dispatcher) up to this point. More... | |
Additional Inherited Members | |
![]() | |
void | AddIdleServer (ParallelJobServerBase< JobContainerType > server) |
Adds the specified parallel job server to the idle list. More... | |
void | RemoveIdleServer (ParallelJobServerBase< JobContainerType > server) |
Removes the specified parallel job server from the idle list. More... | |
ParallelJobServerBase < JobContainerType > | GetFirstIdleServer () |
Returns the first idle server (last on the list of idle servers) and removes it from the idle servers list, or returns null if there are no idle servers. More... | |
void | EnqueueJob (JobContainerType jobData) |
Adds the specified job container to the execution queue. More... | |
JobContainerType | DequeueJob () |
Removes the last job from the execution queue and returns it, or returns null if there are no jobs on the queue. More... | |
virtual void | UpdateThreadPriorityFromSystem () |
Updates thread priority (property ThreadPriority) to the current global thread priority (the UtilSystem.ThreadPriority property). More... | |
void | Serve () |
Method executed in the queue server thread. Excecutes eventual enqueued jobs as job servers become idle. More... | |
![]() | |
void | ResetNumIdleJobServers () |
Resets number of idle job servers to 0. More... | |
![]() | |
static int | GetNextId () |
Returns another ID that is unique for objects of the containing class its and derived classes. More... | |
![]() | |
readonly List < ParallelJobServerBase < JobContainerType > > | _jobServers |
List of job servers contained by the current dispatcher. More... | |
readonly List < ParallelJobServerBase < JobContainerType > > | _idleJobServers |
List of idle job servers dispatched by teh current dispatcher. More... | |
Queue< JobContainerType > | _jobQueue = new Queue<JobContainerType>() |
Queue of jobs that could not be immediately served, scheduled for later execution. More... | |
bool | _commandStopServing = false |
bool | _systemPriorityUpdatesRegistered = false |
Whether the "event" handler for system priprity changes has already been registered. More... | |
ThreadPriority | _threadPriority = UtilSystem.ThreadPriority |
Thread | _workingThread |
bool | _isServerRunning = false |
![]() | |
readonly object | ServersLock = new object() |
Lock that is usef for locking code that can be run from servers. More... | |
volatile int | _outputLevel = ParallelJobContainerBase.DefaultOutputLevel |
Output level for objects of this class. More... | |
bool | _isTestMode = ParallelJobContainerBase.DefaultIsTestMode |
int | _sleepTimeMs = DefaultSleepTimeMs |
int | _numSentJobs = 0 |
![]() | |
int | NumEnqueuedJobs [get] |
Gets the number of enqueued jobs. More... | |
int | NumJobServers [get] |
number of job cervers that are currently asigned to hte dispatcher. More... | |
int | NumActiveJobServers [get] |
Gets number of active job servers assigned to the dispatcher. More... | |
int | NumExecutingJobs [get] |
Gets number of currently executing jobs. More... | |
bool | CommandStopServing [get, protected 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). More... | |
ThreadPriority | ThreadPriority [get, set] |
Priority of the dispatcher and contained server threads. 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... | |
static int | DefaultOutputLevel [get, set] |
Default output level for objects of this and derived types. More... | |
int | OutputLevel [get, set] |
Output level the current object. More... | |
static bool | DefaultIsTestMode [get, set] |
Default value of test mode flag. 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 | Id [get] |
Unique ID for objects of the currnet and derived classes. 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 | NumIdleJobServers [get] |
Gets the number of idle job servers that are currently available on the dispatcher. More... | |
int | NumSentJobs [get] |
Gets the number of sent jobs (all jobs sent to the current dispatcher for execution). More... | |
int | NumStartedJobs [get] |
Gets the number of jobs started by the dispatcher up to this point. More... | |
int | NumFinishedJobs [get] |
Gets the number of finished jobs (of those handled by the current dispatcher) up to this point. More... | |
int | NumAbortedJobs [get] |
Gets the number of aborted jobs (of those handled by the current dispatcher) up to this point. More... | |
int | NumUncompletedJobs [get] |
Gets the number of idle job runners that are currently available on the dispatcher. More... | |
![]() | |
object | Lock [get] |
![]() | |
int | Id [get] |
Returns unique ID (in the scope of a given type) of the current object. More... | |
Parallel job dispatcher for job containers that inherit from ParallelJobContainerGen.
InputType | Type of inpout data for jobs. |
ResultType | Type of output data for jobs. |
JobContainerType | Type of the job data container used by this parallel server class. It must be be of type ParallelJobContainer<InputType, ResultType>, or must derive form this type. |
JobContainerType | : | ParallelJobContainerGen | |
JobContainerType | : | InputType | |
JobContainerType | : | ResultType |
|
inline |