In my header file, I have the following declaration under private
:
void *computeSignalBlock(void *);
Now, I fail to compile attempting to pass this method to the pthread_create method. The error is:
cannot convert ‘medianfilter::computeSignalBlock’ from
type ‘void* (medianfilter::)(void*)’ to type ‘void* (*)(void*)’
Why is that looking at my implementations below?
void medianfilter::computeFilteredResults(vector<float> _signals, int _nThreads,
int _windowSize, bool _isParallel) {
// Set instance variables.
originalSignalVector = _signals;
nThreads = _nThreads;
windowSize = _windowSize;
isParallel = _isParallel;
// Create the threads,
pthread_t threads[nThreads];
pthread_attr_t attr;
// Initialize and set thread joinable
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
for (int i = 0; i < nThreads; i++) {
pthread_create(&threads[i], NULL, computeSignalBlock, (void *) i);
}
}
void *medianfilter::computeSignalBlock(void *block) {
//TODO I need access to instance variables!
}