C# Class multithreading.JobCenter.Worker

Represents a worker. A worker does work. One can assign as many jobs to him, as one likes. They all get stored in a queue, which the worker works on. You can rest while he's doing your work and he will wake you up, if he's finished. If there are no jobs to do for the moment, the worker rests, releasing system resources. A worker is implemented as a thread, so creating multiple workers and letting them work on independent jobs grants a performance benefit on multi processor systems. Or you just can realize asnychronous operations (on a single processer system).
Afficher le fichier Open project: denniskb/asvo

Méthodes publiques

Свойство Type Description
id int

Méthodes publiques

Méthode Description
Worker ( )

Creates a new worker and assigns it a unique id. Workers should be reused throuout the execution time rather than being destroyed and recreated.

assignJob ( IJob job ) : void

Assigns this worker a job which gets inserted into the worker's job queue.

getWorkerCount ( ) : int

Returns the count of all created workers since application start.

join ( ) : void

Puts the calling thread to sleep, until the worker has finished all his work.

start ( ) : void

Starts this worker's every day work described in the class summary.

Private Methods

Méthode Description
doWork ( ) : void

(Fetch job -> execute -> sleep)-loop described in the class summary.

Method Details

Worker() public méthode

Creates a new worker and assigns it a unique id. Workers should be reused throuout the execution time rather than being destroyed and recreated.
public Worker ( )

assignJob() public méthode

Assigns this worker a job which gets inserted into the worker's job queue.
public assignJob ( IJob job ) : void
job IJob The job to be exectued by the worker.
Résultat void

getWorkerCount() public static méthode

Returns the count of all created workers since application start.
public static getWorkerCount ( ) : int
Résultat int

join() public méthode

Puts the calling thread to sleep, until the worker has finished all his work.
public join ( ) : void
Résultat void

start() public méthode

Starts this worker's every day work described in the class summary.
public start ( ) : void
Résultat void

Property Details

id public_oe property

public int id
Résultat int