C# 클래스 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).
파일 보기 프로젝트 열기: denniskb/asvo

공개 프로퍼티들

프로퍼티 타입 설명
id int

공개 메소드들

메소드 설명
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.

비공개 메소드들

메소드 설명
doWork ( ) : void

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

메소드 상세

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.
public Worker ( )

assignJob() 공개 메소드

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.
리턴 void

getWorkerCount() 공개 정적인 메소드

Returns the count of all created workers since application start.
public static getWorkerCount ( ) : int
리턴 int

join() 공개 메소드

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

start() 공개 메소드

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

프로퍼티 상세

id 공개적으로 프로퍼티

public int id
리턴 int