gearman_worker_add_function.rst 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. =================================
  2. Create a function with a callback
  3. =================================
  4. --------
  5. SYNOPSIS
  6. --------
  7. #include <libgearman/gearman.h>
  8. .. c:type:: gearman_worker_fn
  9. .. c:function:: gearman_return_t gearman_worker_add_function(gearman_worker_st *worker, const char *function_name, uint32_t timeout, gearman_worker_fn *function, void *context)
  10. Compile and link with -lgearman
  11. -----------
  12. DESCRIPTION
  13. -----------
  14. :c:func:`gearman_worker_add_function` adds function with a callback to a :c:type:`gearman_worker_st` .
  15. A :c:type:`gearman_job_st` is passed to the callback, it can be used to send messages to the client about the state of the work.
  16. The context provided will only be shared with the function created.
  17. To remove the function call :c:func:`gearman_worker_unregister`.
  18. ------------
  19. RETURN VALUE
  20. ------------
  21. :c:func:`gearman_worker_add_function` returns a :c:type:`gearman_return_t` with either :c:type:`GEARMAN_SUCCESS`, or an error. Additional information on the error can be found with :c:function::`gearman_worker_error`
  22. ----
  23. HOME
  24. ----
  25. To find out more information please check:
  26. `https://gearman.org/gearmand/ <https://gearman.org/gearmand/>`_
  27. --------
  28. SEE ALSO
  29. --------
  30. :manpage:`gearmand(8)` :manpage:`libgearman(3)` :manpage:`gearman_worker_st(3)`