|
Public Member Functions |
bool | StartThreads (int numThreads, int stackSize, void *(*_perThreadDataFactory)()=0, void(*_perThreadDataDestructor)(void *)=0) |
void | StopThreads (void) |
| Stops all threads.
|
void | AddInput (OutputType(*workerThreadCallback)(InputType, bool *returnOutput, void *perThreadData), InputType inputData) |
bool | HasOutput (void) |
bool | HasOutputFast (void) |
bool | HasInput (void) |
bool | HasInputFast (void) |
OutputType | GetOutput (void) |
void | Clear (void) |
| Clears internal buffers.
|
void | LockInput (void) |
void | UnlockInput (void) |
| Unlock the input buffer after you are done with the functions InputSize, GetInputAtIndex, and RemoveInputAtIndex.
|
unsigned | InputSize (void) |
| Length of the input queue.
|
InputType | GetInputAtIndex (unsigned index) |
| Get the input at a specified index.
|
void | RemoveInputAtIndex (unsigned index) |
| Remove input from a specific index. This does NOT do memory deallocation - it only removes the item from the queue.
|
void | LockOutput (void) |
void | UnlockOutput (void) |
| Unlock the output buffer after you are done with the functions OutputSize, GetOutputAtIndex, and RemoveOutputAtIndex.
|
unsigned | OutputSize (void) |
| Length of the output queue.
|
OutputType | GetOutputAtIndex (unsigned index) |
| Get the output at a specified index.
|
void | RemoveOutputAtIndex (unsigned index) |
| Remove output from a specific index. This does NOT do memory deallocation - it only removes the item from the queue.
|
void | ClearInput (void) |
| Removes all items from the input queue.
|
void | ClearOutput (void) |
| Removes all items from the output queue.
|
bool | IsWorking (void) |
| Are any of the threads working, or is input or output available?
|
int | NumThreadsWorking (void) |
| The number of currently active threads.
|
template<class InputType, class OutputType>
void ThreadPool< InputType, OutputType >::AddInput |
( |
OutputType(*)(InputType, bool *returnOutput, void *perThreadData) |
workerThreadCallback, |
|
|
InputType |
inputData | |
|
) |
| | [inline] |
Adds a function to a queue with data to pass to that function. This function will be called from the thread Memory management is your responsibility! This class does not allocate or deallocate memory. The best way to deallocate inputData is in userCallback. If you call EndThreads such that callbacks were not called, you can iterate through the inputQueue and deallocate all pending input data there The best way to deallocate output is as it is returned to you from GetOutput. Similarly, if you end the threads such that not all output was returned, you can iterate through outputQueue and deallocate it there.
- Parameters:
-
[in] | workerThreadCallback | The function to call from the thread |
[in] | inputData | The parameter to pass to userCallback |