Back to index

nordugrid-arc-nox  1.1.0~rc6
Classes | Functions | Variables
arcom.threadpool Namespace Reference

Classes

class  ThreadPool
class  ThreadPoolThread
class  ReadWriteLock

Functions

def sortTask
def waitTask
def addTask
def taskCallback

Variables

int COUNTER = 0
tuple locker = ReadWriteLock()
tuple pool = ThreadPool(3)

Function Documentation

def arcom.threadpool.addTask (   data)

Definition at line 245 of file threadpool.py.

00245 
00246     def addTask(data):
00247         global COUNTER
00248         nadds = 10000
00249         for i in range(nadds):
00250             # re-acquiring lock for every add
00251             # don't do this at home...
00252             locker.acquire_write()
00253             COUNTER += data
00254             locker.release_write()
00255         print "Added %d to counter, counter is now %d"%(data*nadds,COUNTER)
00256         return "addTask", data
    
def arcom.threadpool.sortTask (   data)

Definition at line 225 of file threadpool.py.

00225 
00226     def sortTask(data):
00227         print "SortTask starting for ", data
00228         numbers = range(data[0], data[1])
00229         for a in numbers:
00230             rnd = randrange(0, len(numbers) - 1)
00231             a, numbers[rnd] = numbers[rnd], a
00232         print "SortTask sorting for ", data
00233         numbers.sort()
00234         print "SortTask done for ", data
00235         return "Sorter ", data

Definition at line 259 of file threadpool.py.

00259 
00260     def taskCallback(data):
        print "Callback called for", data
def arcom.threadpool.waitTask (   data)

Definition at line 238 of file threadpool.py.

00238 
00239     def waitTask(data):
00240         print "WaitTask starting for ", data
00241         print "WaitTask sleeping for %d seconds" % data
00242         sleep(data)
00243         return "Waiter", data


Variable Documentation

Definition at line 215 of file threadpool.py.

Definition at line 244 of file threadpool.py.

Definition at line 263 of file threadpool.py.