Package rosmaster :: Module threadpool :: Class MarkedThreadPool

Class MarkedThreadPool

source code

object --+
         |
        MarkedThreadPool

Flexible thread pool class. Creates a pool of threads, then accepts tasks that will be dispatched to the next available thread.

Instance Methods
 
__init__(self, numThreads)
Initialize the thread pool with numThreads workers.
source code
 
set_thread_count(self, newNumThreads)
External method to set the current pool size.
source code
 
get_thread_count(self)
Returns: number of threads in the pool.
source code
 
queue_task(self, marker, task, args=None, taskCallback=None)
Insert a task into the queue.
source code
 
remove_marker(self, marker)
Remove the marker from the currently executing tasks.
source code
 
get_next_task(self)
Retrieve the next task from the task queue.
source code
 
join_all(self, wait_for_tasks=True, wait_for_threads=True)
Clear the task queue and terminate all pooled threads, optionally allowing the tasks and threads to finish.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, numThreads)
(Constructor)

source code 

Initialize the thread pool with numThreads workers.

Overrides: object.__init__

set_thread_count(self, newNumThreads)

source code 

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

get_thread_count(self)

source code 
Returns:
number of threads in the pool.

queue_task(self, marker, task, args=None, taskCallback=None)

source code 

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

remove_marker(self, marker)

source code 

Remove the marker from the currently executing tasks. Only one task with the given marker can be executed at a given time

get_next_task(self)

source code 

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