Package Ganga :: Package Core :: Package GangaThread :: Package MTRunner :: Module MTRunner' :: Class MTRunner
[hide private]
[frames] | no frames]

Class MTRunner

source code


Class to handle multiple concurrent threads running on the same algorithm. 

@since: 0.0.1
@author: Hurng-Chun Lee 
@contact: hurngchunlee@gmail.com

The class itself is a thread. To run it; doing the following:

    runner = MTRunner(myAlgorithm, myData)
    runner.start()
    ... you can do something in parallel in your main program ...
    runner.join()

where 'myAlorithm' and 'myData' are two objects defining your own
algorithm running on a dataset.

Instance Methods [hide private]
 
__cnt_alive_threads__(self) source code
 
__init__(self, name, algorithm=None, data=None, numThread=10, keepAlive=False)
initializes the MTRunner object.
source code
 
addDataItem(self, item)
adds a new data item into the internal queue
source code
 
getDoneList(self)
gets the data items that have been processed correctly by the algorithm.
source code
 
getResults(self)
gets the overall results (e.g.
source code
 
join(self, timeout=-1)
joins the worker agents.
source code
 
start(self)
starts the MTRunner
source code
 
stop(self, timeout=-1)
waits worker agents to finish their works.
source code
Class Variables [hide private]
  _attributes = ('name', 'algorithm', 'data', 'numThread', 'done...
Method Details [hide private]

__init__(self, name, algorithm=None, data=None, numThread=10, keepAlive=False)
(Constructor)

source code 

initializes the MTRunner object.

Since: 0.0.1

Author: Hurng-Chun Lee

Contact: hurngchunlee@gmail.com

@param algorithm is an Algorithm object defining how to process on the data @param data is an Data object defining what to be processed by the algorithm

getResults(self)

source code 

gets the overall results (e.g. output) from the algorithm.

join(self, timeout=-1)

source code 

joins the worker agents.

The caller will be blocked until exceeding the timeout or all worker agents finish their jobs.


Class Variable Details [hide private]

_attributes

Value:
('name',
 'algorithm',
 'data',
 'numThread',
 'doneList',
 'lock',
 'keepAlive')