Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Attributes
test.lock_tests.Bunch Class Reference
Inheritance diagram for test.lock_tests.Bunch:
Inheritance graph
[legend]
Collaboration diagram for test.lock_tests.Bunch:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def wait_for_started
def wait_for_finished
def do_finish

Public Attributes

 f
 n
 started
 finished
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Attributes

 _can_exit

Detailed Description

A bunch of threads.

Definition at line 18 of file lock_tests.py.


Constructor & Destructor Documentation

def test.lock_tests.Bunch.__init__ (   self,
  f,
  n,
  wait_before_exit = False 
)
Construct a bunch of `n` threads running the same function `f`.
If `wait_before_exit` is True, the threads won't terminate until
do_finish() is called.

Definition at line 22 of file lock_tests.py.

00022 
00023     def __init__(self, f, n, wait_before_exit=False):
00024         """
00025         Construct a bunch of `n` threads running the same function `f`.
00026         If `wait_before_exit` is True, the threads won't terminate until
00027         do_finish() is called.
00028         """
00029         self.f = f
00030         self.n = n
00031         self.started = []
00032         self.finished = []
00033         self._can_exit = not wait_before_exit
00034         def task():
00035             tid = get_ident()
00036             self.started.append(tid)
00037             try:
00038                 f()
00039             finally:
00040                 self.finished.append(tid)
00041                 while not self._can_exit:
00042                     _wait()
00043         for i in range(n):
00044             start_new_thread(task, ())

Here is the caller graph for this function:


Member Function Documentation

Definition at line 53 of file lock_tests.py.

00053 
00054     def do_finish(self):
00055         self._can_exit = True
00056 

Definition at line 49 of file lock_tests.py.

00049 
00050     def wait_for_finished(self):
00051         while len(self.finished) < self.n:
00052             _wait()

Here is the call graph for this function:

Definition at line 45 of file lock_tests.py.

00045 
00046     def wait_for_started(self):
00047         while len(self.started) < self.n:
00048             _wait()

Here is the call graph for this function:


Member Data Documentation

Definition at line 32 of file lock_tests.py.

Definition at line 28 of file lock_tests.py.

Definition at line 31 of file lock_tests.py.

Definition at line 29 of file lock_tests.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 30 of file lock_tests.py.


The documentation for this class was generated from the following file: