RuneHive-Game
Loading...
Searching...
No Matches
dev.advo.fs.dispatch.RequestWorkerPool Class Reference

A class which manages the pool of request workers. More...

Public Member Functions

 RequestWorkerPool ()
 The request worker pool.
void start () throws Exception
 Starts the threads in the pool.

Private Attributes

final ExecutorService service
 The executor service.
final List< OnDemandRequestWorkerworkers = new ArrayList<OnDemandRequestWorker>()
 A list of request workers.

Static Private Attributes

static final int THREADS_PER_REQUEST_TYPE = Runtime.getRuntime().availableProcessors()
 The number of threads per request type.

Detailed Description

A class which manages the pool of request workers.

Author
Graham

Definition at line 16 of file RequestWorkerPool.java.

Constructor & Destructor Documentation

◆ RequestWorkerPool()

dev.advo.fs.dispatch.RequestWorkerPool.RequestWorkerPool ( )

The request worker pool.

Definition at line 36 of file RequestWorkerPool.java.

36 {
37 int totalThreads = THREADS_PER_REQUEST_TYPE;
38 service = Executors.newFixedThreadPool(totalThreads);
39 }

References service, and THREADS_PER_REQUEST_TYPE.

Member Function Documentation

◆ start()

void dev.advo.fs.dispatch.RequestWorkerPool.start ( ) throws Exception

Starts the threads in the pool.

Exceptions
Exceptionif the file system cannot be created.

Definition at line 45 of file RequestWorkerPool.java.

45 {
46 File base = new File("./data/cache/");
47
48 for (int i = 0; i < THREADS_PER_REQUEST_TYPE; i++) {
49 workers.add(new OnDemandRequestWorker(new IndexedFileSystem(base, true)));
50 }
51
52 for (OnDemandRequestWorker worker : workers) {
53 service.submit(worker);
54 }
55 }

References service, THREADS_PER_REQUEST_TYPE, and workers.

Member Data Documentation

◆ service

final ExecutorService dev.advo.fs.dispatch.RequestWorkerPool.service
private

The executor service.

Definition at line 26 of file RequestWorkerPool.java.

Referenced by RequestWorkerPool(), and start().

◆ THREADS_PER_REQUEST_TYPE

final int dev.advo.fs.dispatch.RequestWorkerPool.THREADS_PER_REQUEST_TYPE = Runtime.getRuntime().availableProcessors()
staticprivate

The number of threads per request type.

Definition at line 21 of file RequestWorkerPool.java.

Referenced by RequestWorkerPool(), and start().

◆ workers

final List<OnDemandRequestWorker> dev.advo.fs.dispatch.RequestWorkerPool.workers = new ArrayList<OnDemandRequestWorker>()
private

A list of request workers.

Definition at line 31 of file RequestWorkerPool.java.

Referenced by start().


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