GEARMAN_WORKER_CREATE(3)
π GEARMAN_WORKER_CREATE π
okay so bestie, welcome to libgearman land β¨ this is the gearman_worker_create(3) page from the Gearmand Documentation over at http://gearman.info/ β three little functions that birth, copy, and yeet your worker structs. it's giving β¨allocator coreβ¨ and honestly? iconic.
β¨ NAME β¨
gearman_worker_create β Gearmand Documentation, http://gearman.info/
πΈ SYNOPSIS πΈ
first things first, you gotta pull in the header:
#include <libgearman/gearman.h>
gearman_worker_st
*gearman_worker_create(gearman_worker_st *client)
gearman_worker_st
*gearman_worker_clone(gearman_worker_st *client,
const gearman_worker_st *from)
void gearman_worker_free(gearman_worker_st
*client)
and then when you link, don't forget:
Link with -lgearman
no cap, if you skip -lgearman the linker will simply not know her π
π DESCRIPTION π
gearman_worker_create() is the main character here π
you use it to make a gearman_worker_st structure, and then all the other libgearman(3) client functions use that structure to talk to the server. yes bestie, she's the plug.
so here's the vibe: you either hand her a statically declared gearman_worker_st, or you hand her a NULL. that's it. that's the choice. if you pass a NULL in, then a structure gets allocated for you π«Ά
gearman_worker_clone() is basically gearman_worker_create()'s sibling π― it does the same thing BUT it also copies over the defaults and the list of servers from the source gearman_worker_st. so like, she comes pre-filled.
- if you pass a null as the argument for the source you're cloning? that's literally the exact same as calling
gearman_worker_create()π - if the destination argument is
NULL, agearman_worker_stwill be allocated for you β¨
then, when you're done and you want to clean up all the memory hanging off a gearman_worker_st structure, you pass it to gearman_worker_free(). and listen β gearman_worker_free is the only way to make sure all the memory is deallocated when you finish using the structure. do not freelance this one π
β οΈ okay real talk for a sec because this one matters: you may wish to avoid usinggearman_worker_create()orgearman_worker_clone()with a stack based allocation, i.e. the first parameter. the most common issues related to ABI safety involve heap allocated structures. so like, heap it. please. for me. π§
π RETURN VALUE π
gearman_worker_create()returns a pointer to thegearman_worker_stthat was created (or initialized). on an allocation failure, it returnsNULLπgearman_worker_clone()returns a pointer to thegearman_worker_stthat was created (or initialized). on an allocation failure, it returnsNULLπ
so yeah. pointer on success, NULL when the allocator says no. check it. always check it. π«Ά
π HOME π
to find out more information please check: http://gearman.info/
See also:
π Author π
Data Differential http://www.datadifferential.com/
β Copyright β
2011-2014, Data Differential, http://www.datadifferential.com/
and that's the whole page, bestie, you ate that π this was GEARMAN_WORKER_CREATE(3) from the Gearmand manual, version 1.1.21+ds, dated Feb 04, 2026 β go forth and allocate responsibly, and remember: gearman_worker_free or it didn't happen π
β¨π¦
π¦ where this page comes from
- ubuntu resolute: libgearman-dev 1.1.21+ds-1ubuntu3 Β· BSD-3-Clause
- ubuntu stonking: libgearman-dev 1.1.21+ds-1ubuntu3 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms