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

A class which dispatches requests to worker threads. More...

Static Public Member Functions

static void dispatch (Channel channel, OnDemandRequest request)
 Dispatches an 'on-demand' request.

Static Package Functions

static ChannelRequest< OnDemandRequestnextOnDemandRequest () throws InterruptedException
 Gets the next 'on-demand' request from the queue, blocking if none are available.

Private Member Functions

 RequestDispatcher ()
 Default private constructor to prevent instantiation.

Static Private Attributes

static final int MAXIMUM_QUEUE_SIZE = 1024
 The maximum size of a queue before requests are rejected.
static final BlockingQueue< ChannelRequest< OnDemandRequest > > onDemandQueue = new PriorityBlockingQueue<ChannelRequest<OnDemandRequest>>()
 A queue for pending 'on-demand' requests.

Detailed Description

A class which dispatches requests to worker threads.

Author
Graham

Definition at line 14 of file RequestDispatcher.java.

Constructor & Destructor Documentation

◆ RequestDispatcher()

dev.advo.fs.dispatch.RequestDispatcher.RequestDispatcher ( )
private

Default private constructor to prevent instantiation.

Definition at line 51 of file RequestDispatcher.java.

51 {
52
53 }

Member Function Documentation

◆ dispatch()

void dev.advo.fs.dispatch.RequestDispatcher.dispatch ( Channel channel,
OnDemandRequest request )
static

Dispatches an 'on-demand' request.

Parameters
channelThe channel.
requestThe request.

Definition at line 41 of file RequestDispatcher.java.

41 {
42// if (onDemandQueue.size() >= MAXIMUM_QUEUE_SIZE) {
43// channel.close();
44// }
45 onDemandQueue.add(new ChannelRequest<OnDemandRequest>(channel, request));
46 }

References onDemandQueue.

Referenced by dev.advo.fs.net.FileServerHandler.messageReceived().

Here is the caller graph for this function:

◆ nextOnDemandRequest()

ChannelRequest< OnDemandRequest > dev.advo.fs.dispatch.RequestDispatcher.nextOnDemandRequest ( ) throws InterruptedException
staticpackage

Gets the next 'on-demand' request from the queue, blocking if none are available.

Returns
The 'on-demand' request.
Exceptions
InterruptedExceptionif the thread is interrupted.

Definition at line 32 of file RequestDispatcher.java.

32 {
33 return onDemandQueue.take();
34 }

References onDemandQueue.

Referenced by dev.advo.fs.dispatch.OnDemandRequestWorker.nextRequest().

Here is the caller graph for this function:

Member Data Documentation

◆ MAXIMUM_QUEUE_SIZE

final int dev.advo.fs.dispatch.RequestDispatcher.MAXIMUM_QUEUE_SIZE = 1024
staticprivate

The maximum size of a queue before requests are rejected.

Definition at line 19 of file RequestDispatcher.java.

◆ onDemandQueue

final BlockingQueue<ChannelRequest<OnDemandRequest> > dev.advo.fs.dispatch.RequestDispatcher.onDemandQueue = new PriorityBlockingQueue<ChannelRequest<OnDemandRequest>>()
staticprivate

A queue for pending 'on-demand' requests.

Definition at line 24 of file RequestDispatcher.java.

Referenced by dispatch(), and nextOnDemandRequest().


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