Package com.martiansoftware.nailgun
Class NGSessionPool
- java.lang.Object
-
- com.martiansoftware.nailgun.NGSessionPool
-
class NGSessionPool extends java.lang.Object
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
Fields Modifier and Type Field Description (package private) boolean
done
have we been shut down?private java.lang.Object
lock
synchronization object(package private) NGSession[]
pool
the pool itself(package private) int
poolEntries
The number of sessions currently in the pool(package private) int
poolSize
number of sessions to store in the pool(package private) NGServer
server
reference to server we're working for
-
Constructor Summary
Constructors Constructor Description NGSessionPool(NGServer server, int poolsize)
Creates a new NGSessionRunner operating for the specified server, with the specified number of threads
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
give(NGSession session)
Returns an NGSession to the pool.(package private) void
shutdown()
Shuts down the pool.(package private) NGSession
take()
Returns an NGSession from the pool, or creates one if necessary
-
-
-
Field Detail
-
poolSize
final int poolSize
number of sessions to store in the pool
-
pool
final NGSession[] pool
the pool itself
-
poolEntries
int poolEntries
The number of sessions currently in the pool
-
server
final NGServer server
reference to server we're working for
-
done
boolean done
have we been shut down?
-
lock
private final java.lang.Object lock
synchronization object
-
-
Constructor Detail
-
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 Detail
-
take
NGSession take()
Returns an NGSession from the pool, or creates one if necessary- Returns:
- an NGSession ready to work
-
give
void give(NGSession session)
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.
-
-