gearman_worker_create.rst 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ===================================
  2. Creating Gearman Worker Connections
  3. ===================================
  4. --------
  5. SYNOPSIS
  6. --------
  7. #include <libgearman/gearman.h>
  8. .. c:function:: gearman_worker_st *gearman_worker_create(gearman_worker_st *client)
  9. .. c:function:: gearman_worker_st *gearman_worker_clone(gearman_worker_st *client, const gearman_worker_st *from)
  10. .. c:function:: void gearman_worker_free(gearman_worker_st *client)
  11. Link with -lgearman
  12. -----------
  13. DESCRIPTION
  14. -----------
  15. gearman_worker_create() is used to create a :c:type:`gearman_worker_st` structure that will then
  16. be used by other libgearman(3) client functions to communicate with the server. You
  17. should either pass a statically declared :c:type:`gearman_worker_st` to gearman_worker_create) or
  18. a NULL. If a NULL passed in then a structure is allocated for you.
  19. :c:func:`gearman_worker_clone` is similar to :c:func:`gearman_worker_create` but it copies the
  20. defaults and list of servers from the source :c:type:`gearman_worker_st`. If you pass a null as
  21. the argument for the source to clone, it is the same as a call to gearman_worker_create().
  22. If the destination argument is NULL a :c:type:`gearman_worker_st` will be allocated for you.
  23. To clean up memory associated with a :c:type:`gearman_worker_st` structure you should pass
  24. it to :c:func:`gearman_worker_free` when you are finished using it. :c:type:`gearman_worker_free` is
  25. the only way to make sure all memory is deallocated when you finish using
  26. the structure.
  27. You may wish to avoid using :c:func:`gearman_worker_create` or :c:func:`gearman_worker_clone` with a
  28. stack based allocation, ie the first parameter. The most common issues related to ABI safety involve
  29. heap allocated structures.
  30. ------------
  31. RETURN VALUE
  32. ------------
  33. :c:func:`gearman_worker_create` returns a pointer to the :c:type:`gearman_worker_st` that was created
  34. (or initialized). On an allocation failure, it returns NULL.
  35. :c:func:`gearman_worker_clone` returns a pointer to the :c:type:`gearman_worker_st` that was created
  36. (or initialized). On an allocation failure, it returns NULL.
  37. ----
  38. HOME
  39. ----
  40. To find out more information please check:
  41. `https://gearman.org/gearmand/ <https://gearman.org/gearmand/>`_
  42. .. seealso::
  43. :manpage:`gearmand(8)` :manpage:`libgearman(3)` :manpage:`gearman_strerror(3)`