casa
$Rev:20696$
|
-*- C++ -*- More...
-*- C++ -*-
Code in the master thread: ThreadCoordinator threadCoordinator (nThreads);
Create nThread threads and pass them a pointer to the thread coordinator object. Then enter the work loop
for (int i = 0; i < nBuffers; i++){
Provide access to the i-th buffer
threadCoordinator->getToWork(& vb); // tell workers to hop to it!
blocks if workers still busy
} Code in each worker thread: while (True){ VisBuffer * workingBuffer = threadCoordinator_p->waitForWork (this); if (workingBuffer == NULL) break; doSomeWork(workingBuffer);