用 C 创建 Gearman Worker
我一直在尝试使用他们的 C API (libgearman) 来实现 Gearman 工作线程。但他们的 C API 文档很差而且不完整。虽然它与使用 PHP 等其他语言创建工作线程非常相似,但我仍然无法通过 *gearman_worker_add_function();* 在工作线程中注册函数;
具体来说,我无法找到如何创建 *gearman_worker_fn 的对象*。
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据此文档:
这是一个函数指针 typedef:基本上你只需要创建一个具有正确签名的函数(返回
void *
,接受gearman_job_st *
,void *,
size_t *
,gearman_return_t *
),然后传入函数名。示例:
请注意,我只是传递了函数名称——这会降级为“函数指针”。
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".