I have a question regarding a callback that uses threads for a mysql connection. I can't access data member connectionPool in static function worker_thread. Is it possible or is there a way round this?
Yes you cannot use member data in static functions. The general way to implement thread functions in these scenarios is to send "this" pointer as the parameter to the thread function. Using the this pointer you can access the private members of the class.
Sorry for the late reply.
I'm still a bit confused - so I would have to create another "thread_arg_t arg2" parameter for the create_thread function which would be the "this" pointer ?
your worker_thread static callback function should take a void* argument - that void* argument can be cast back to what you passed in as running + i on Line 3
you should convert the this pointer to void* and pass to the function pthread_create of the param arg,then in work_thread convert it back before using.