GEARMAN_WORKER_WAIT(3)

✨ gearman_worker_wait ✨ (the gearmand docs, section 3)

okay bestie, sit down, hydrate, and let's talk about gearman_worker_wait from the Gearmand docs πŸ’… this one lives at http://gearman.info/ and it's basically the whole worker-side vibe of libgearman in one page. no cap.


🌸 SYNOPSIS 🌸

first things first, you gotta pull in the header:

#include <libgearman/gearman.h>

and here's the whole cast of characters, exactly as advertised:

type gearman_worker_st

type gearman_worker_set_task_context_free_fn

int gearman_worker_timeout(gearman_worker_st *worker)

void gearman_worker_set_timeout(gearman_worker_st *worker, int timeout)

void *gearman_worker_context(const gearman_worker_st *worker)

void gearman_worker_set_context(gearman_worker_st *worker, void *context)

void gearman_worker_set_workload_malloc_fn(gearman_worker_st *worker,
        gearman_malloc_fn <#c.gearman_malloc_fn> *function, void *context)

void gearman_worker_set_workload_free_fn(gearman_worker_st *worker,
        gearman_free_fn <#c.gearman_free_fn> *function, void *context)

gearman_return_t <#c.gearman_return_t>
gearman_worker_wait(gearman_worker_st *worker)

gearman_return_t <#c.gearman_return_t>
gearman_worker_register(gearman_worker_st *worker, const char
        *function_name, uint32_t <#c.uint32_t> timeout)

gearman_return_t <#c.gearman_return_t>
gearman_worker_unregister(gearman_worker_st *worker, const char
        *function_name)

gearman_return_t <#c.gearman_return_t>
gearman_worker_unregister_all(gearman_worker_st *worker)

void gearman_job_free_all(gearman_worker_st *worker)

bool gearman_worker_function_exist(gearman_worker_st *worker, const char
        *function_name, size_t <#c.size_t> function_length)

gearman_return_t <#c.gearman_return_t>
gearman_worker_work(gearman_worker_st *worker)

gearman_job_st <#c.gearman_job_st>
*gearman_worker_grab_job(gearman_worker_st *worker, gearman_job_st <#c
.gearman_job_st> *job, gearman_return_t <#c.gearman_return_t> *ret_ptr)

Link with -lgearman
⚠️ bestie don't forget that last line β€” you have to Link with -lgearman or the linker will simply not know you πŸ’€

πŸ¦‹ DESCRIPTION πŸ¦‹

gearman_worker_st is the whole ✨main character✨ struct β€” it's what a worker uses to talk to the server. everything else on this page orbits around it.

  • gearman_worker_context() and gearman_worker_set_context() let you stash an arbitrary object of your very own in there. it's your drawer. put whatever you want in it. user data rights!! πŸŽ€
  • gearman_worker_set_task_context_free_fn() sets up a trigger that gets called when a gearman_task_st <#c.gearman_task_st> is released. it's giving cleanup crew 🧹✨
  • gearman_worker_timeout() and gearman_worker_set_timeout() get and set the current timeout value for the worker β€” and heads up, that value is in milliseconds. ms, babe. not seconds. πŸ•°οΈ
  • gearman_worker_function_exist() is your little detective πŸ” β€” you use it to figure out whether a given worker has a specific function.
  • gearman_worker_work() makes the worker just execute against jobs until an error occurs. it goes and goes and goes until something goes wrong. periodt.
  • gearman_worker_grab_job() takes a job from one of the job servers. and listen β€” it is the responsibility of the caller to free the job once they're done. no one's gonna do it for you, bestie 😭 also, real talk: this interface is used in testing, and it is very rarely the correct interface to program against. so like... know that before you commit. ngl.
  • normally malloc(3) and free(3) handle allocating and releasing workloads. but if you want custom ones you can swap them out with gearman_worker_set_workload_malloc_fn() and gearman_worker_set_workload_free_fn(). bring your own allocator, it's fine, we support you 🫢
  • and if you gotta remove a function from the server, you've got two roads: gearman_worker_unregister_all() to nuke all the functions the worker told the gearmand server about 🌈, or gearman_worker_unregister() to remove just one single function. precise. demure. πŸ’…

⭐ RETURN ⭐

Various

yep. that's the whole answer. various. iconic, honestly. πŸ‘‘


🏠 HOME 🏠

want more? go touch grass... no wait, go touch the docs: <http://gearman.info/> 🌸


🫢 SEE ALSO 🫢


πŸ’œ Author πŸ’œ

Data Differential http://www.datadifferential.com/

2011-2014, Data Differential, http://www.datadifferential.com/


and that's the whole page, bestie!! this little slice of the manual is version 1.1.21+ds, dated Feb 04, 2026, and it's still out here doing the most for GEARMAN_WORKER_WAIT(3) πŸ¦‹βœ¨ go forth and register some functions, you got this πŸ’–

πŸ“¦ where this page comes from