I’ve been trying to implement a Gearman worker with their C API (libgearman). But their documentation for the C API is poor and not complete. Although its very similar to creating workers in other languages such as PHP, I am still unable to Register a function in the worker via *gearman_worker_add_function();*
To be specific, I am unable to find out how to create an object of *gearman_worker_fn* .
Thanks!
According to this documentation:
This is a function pointer typedef: Basically you just need to create a function with the correct signature (returns
void *, takes ingearman_job_st *,void *,size_t *,gearman_return_t *), and then pass in the function name.Example:
Notice that I just pass the function name– this degrades to a “function pointer”.