The Thread class provides more options in what can be passed as a target
function, has a built-in progress report mechanism, and allows querying the
result of the target function.
The ThreadedProcessor class offers interruptible threaded batch processing
with arbitrary callables (e.g., for threaded processing of a large number of
images with the same algorithm).
features a) a mechanism to report a thread`s progress (if the
target function defines an "update" keyword argument, it is
passed a function that can be passed arbitrary data reflecting
the thread`s state); b) the possibility to specify instance
methods and class instances with a __call__ method as target
functions; and c) a result value that can be queried with the
.getResult method.
if the target function was set up to call .setUpdate to report the
thread`s progress, call this function from the main thread to get this
progress information (e.g., to update a GUI indicator or some such...).
if the target function for the thread accepts an "update" argument,
it will get passed to this method. Call it in your thread whenever the
thread`s state changes.
uses a WorkerThreadPool to do the hard work. This class is
useful whenever you have to call the same routine with the same
arguments on a large number of items and want to either distribute
the work across several processors, or be able to interrupt the
processing, or both.
Note that you have to set up a loop in your main program that
calls .poll until it returns a non-None value.
queues all items in the sequence`itemL` for threaded processing.
Each element in itemL is going to be the first argument for each
call to the callback specified in the constructor, followed by
additional positional arguments given in args and keyword arguments
given in options. An exception to this rules are tuples as elements
in itemL; these are prepended to the list of positional arguments.
queues the callable callback with positional arguments args and
keyword arguments options for threaded processing. key is an
integer that is used to identify the result returned by .poll.
returns None or the most current result from the result queue,
which will be a 2-tuple (<key>,<returnvalue>) consisting of the
key and the result of the call defined by the arguments to a previous
call to .feed. Note that results are by no means returned in the same
order as they are fed into the queue (which is why we keep the key
around...).