Package nxlucene :: Module threadpool :: Class ThreadPool
[show private | hide private]
[frames | no frames]

Class ThreadPool


Flexible thread pool class. Creates a pool of threads, then accepts tasks that will be dispatched to the next available thread.
Method Summary
  __init__(self, numThreads)
Initialize the thread pool with numThreads workers.
  getNextTask(self)
Retrieve the next task from the task queue.
  getThreadCount(self)
Return the number of threads in the pool.
  joinAll(self, waitForTasks, waitForThreads)
Clear the task queue and terminate all pooled threads, optionally allowing the tasks and threads to finish.
  queueTask(self, task, args, taskCallback)
Insert a task into the queue.
  setThreadCount(self, newNumThreads)
External method to set the current pool size.

Method Details

__init__(self, numThreads)
(Constructor)

Initialize the thread pool with numThreads workers.

getNextTask(self)

Retrieve the next task from the task queue. For use only by ThreadPoolThread objects contained in the pool.

getThreadCount(self)

Return the number of threads in the pool.

joinAll(self, waitForTasks=True, waitForThreads=True)

Clear the task queue and terminate all pooled threads, optionally allowing the tasks and threads to finish.

queueTask(self, task, args=None, taskCallback=None)

Insert a task into the queue. task must be callable; args and taskCallback can be None.

setThreadCount(self, newNumThreads)

External method to set the current pool size. Acquires the resizing lock, then calls the internal version to do real work.

Generated by Epydoc 2.1 on Fri Jun 30 16:38:47 2006 http://epydoc.sf.net