| java.lang.Object com.mckoi.database.WorkerPool
WorkerPool | final class WorkerPool (Code) | | Maintains a pool of worker threads that are used to dispatch commands to
a Database sub-system.
author: Tobias Downer |
Method Summary | |
final public DebugLogger | Debug() Returns a DebugLogger object that we can use to log debug messages. | void | execute(User user, DatabaseConnection database, Runnable runner) Executes database functions from the 'run' method of the given runnable
instance on a worker thread. | void | notifyWorkerReady(WorkerThread worker_thread) This is called by a WorkerThread when it is decided that it is ready
to service a new command. | void | setIsExecutingCommands(boolean status) Controls whether the database is allowed to execute commands or not. | void | shutdown() Shuts down the WorkerPool object stopping all worker threads. | void | waitUntilAllWorkersQuiet() Waits until all executing commands have stopped. |
Debug | final public DebugLogger Debug()(Code) | | Returns a DebugLogger object that we can use to log debug messages.
|
execute | void execute(User user, DatabaseConnection database, Runnable runner)(Code) | | Executes database functions from the 'run' method of the given runnable
instance on a worker thread. All database functions should go through
a worker thread. If we ensure this, we can easily stop all database
functions from executing. Also, we only need to have a certain number
of threads active at any one time rather than a unique thread for each
connection.
|
notifyWorkerReady | void notifyWorkerReady(WorkerThread worker_thread)(Code) | | This is called by a WorkerThread when it is decided that it is ready
to service a new command.
|
setIsExecutingCommands | void setIsExecutingCommands(boolean status)(Code) | | Controls whether the database is allowed to execute commands or not. If
this is set to true, then calls to 'execute' will make commands execute.
|
shutdown | void shutdown()(Code) | | Shuts down the WorkerPool object stopping all worker threads.
|
waitUntilAllWorkersQuiet | void waitUntilAllWorkersQuiet()(Code) | | Waits until all executing commands have stopped. This is best called
right after a call to 'setIsExecutingCommands(false)'. If these two
commands are run, the database is in a known state where no commands
can be executed.
NOTE: This can't be called from the WorkerThread. Deadlock will
result if we were allowed to do this.
|
|
|