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) booleanhave we been shut down?private final Objectsynchronization object(package private) final NGSession[]the pool itself(package private) intThe number of sessions currently in the pool(package private) final intnumber of sessions to store in the pool(package private) final NGServerreference 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
final int poolSizenumber of sessions to store in the pool -
pool
the pool itself -
poolEntries
int poolEntriesThe number of sessions currently in the pool -
server
reference 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.
-