Package com.martiansoftware.nailgun
Class NGSessionPool
java.lang.Object
com.martiansoftware.nailgun.NGSessionPool
Provides NGSession pooling functionality. One parameter, "maxIdle",
governs its behavior by setting the maximum number of idle NGSession
threads it will allow. It creates a pool of size maxIdle - 1, because
one NGSession is kept "on deck" by the NGServer in order to eke out
a little extra responsiveness.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean
have we been shut down?private Object
synchronization object(package private) NGSession[]
the pool itself(package private) int
The number of sessions currently in the pool(package private) int
number of sessions to store in the pool(package private) NGServer
reference to server we're working for -
Constructor Summary
ConstructorsConstructorDescriptionNGSessionPool
(NGServer server, int poolsize) Creates a new NGSessionRunner operating for the specified server, with the specified number of threads -
Method Summary
-
Field Details
-
poolSize
int poolSizenumber of sessions to store in the pool -
pool
NGSession[] poolthe pool itself -
poolEntries
int poolEntriesThe number of sessions currently in the pool -
server
NGServer serverreference to server we're working for -
done
boolean donehave we been shut down? -
lock
synchronization object
-
-
Constructor Details
-
NGSessionPool
NGSessionPool(NGServer server, int poolsize) Creates a new NGSessionRunner operating for the specified server, with the specified number of threads- Parameters:
server
- the server to work forpoolsize
- the maximum number of idle threads to allow
-
-
Method Details
-
take
NGSession take()Returns an NGSession from the pool, or creates one if necessary- Returns:
- an NGSession ready to work
-
give
Returns an NGSession to the pool. The pool may choose to shutdown the thread if the pool is full- Parameters:
session
- the NGSession to return to the pool
-
shutdown
void shutdown()Shuts down the pool. Running nails are allowed to finish.
-