#include <avir.h>
Classes | |
class | CWorkload |
Public Member Functions | |
virtual void | addWorkload (CWorkload *const Workload) |
virtual int | getSuggestedWorkloadCount () const |
virtual void | removeAllWorkloads () |
virtual void | startAllWorkloads () |
virtual void | waitAllWorkloadsToFinish () |
Thread pool for multi-threaded image resizing operation.
This base class is used to organize a multi-threaded image resizing operation. The thread pool should consist of threads that initially wait for a signal. Upon receiving a signal (via the startAllWorkloads() function) each previously added thread should execute its workload's process() function once, and return to the wait signal state again. The thread pool should be also able to efficiently wait for all workloads to finish via the waitAllWorkloadsToFinish() function.
The image resizing algorithm makes calls to functions of this class.
|
virtual |
Function adds a new workload (and possibly thread) to the thread pool. The caller decides how many parallel workloads (and threads) it requires, but this number will not exceed the value returned by the getSuggestedWorkloadCount() function. It is implementation-specific how many workloads to associate with a single thread. But for efficiency reasons each workload should be associated with its own thread.
Note that the same set of workload objects will be processed each time the startAllWorkloads() function is called. This means that workload objects are added only once. The caller changes the state of the workload objects and then calls the startAllWorkloads() function to process them.
Workload | Workload object whose process() function will be called from within the thread when the startAllWorkloads() function is called. |
|
virtual |
|
virtual |
Function removes all workloads previously added via the addWorkload() function. This function gets called only after the waitAllWorkloadsToFinish() function call.
|
virtual |
Function starts all workloads associated with threads previously added via the addWorkload() function. It is assumed that this function performs the necessary "memory barrier" (or "cache sync") kind of operation so that all threads catch up the prior changes made to the workload objects during their wait state.
|
virtual |
Function waits for all workloads to finish.