function type for the worker task
dvhh opened this issue · 1 comments
task are of type
void *(*function_p)(void*)
http://cdecl.ridiculousfish.com/?q=void+*%28*function_p%29%28void*%29
where I believe they should be
void (*function_p)(void*)
http://cdecl.ridiculousfish.com/?q=void+%28*function_p%29%28void*%29
I believe that I causes a bus error when you try to put the first type on the pool and the manager would try to pull them from the pool, plus there is no way to return whatever the worker return, except via output parameters
Do you have a specific issue with the code? What do you mean with 'bus error'?
There shouldn't be a problem no matter if a function returns void or a pointer to void. You are not supposed to return anything from a function added to the pool anyway. It's just how threadpools work. To whom would they return for example? The manager? The user? In both cases things would become way too complex for no benefit since you would need synchronisation mechanisms everywhere and ways for the user to get those return values - really ugly.
If you want to 'return' something from your task simply use globals. People tend to have a bad look on globals but in cases like this, globals are the best way to do things. You can even use a mutex on your global so that many tasks in the threadpool work on the same thing. That makes things simpler and you know exactly what is going on.