gearman_client.rst 2.3 KB

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