GEARMAN_WORKER_SET_CONTEXT(3)
β¨ GEARMAN_WORKER_SET_CONTEXT β¨
okay so bestie, this is a libgearman man page, from the Gearmand docs over at http://gearman.info/ β and we're about to get into worker context, timeouts, workload allocators and all that good stuff. grab a strawberry π and let's go.
πΈ NAME πΈ
gearman_worker_set_context β the Gearmand Documentation situation, http://gearman.info/
π SYNOPSIS π
#include <libgearman/gearman.h>
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)
and yeah β you link it with -lgearman. don't forget that part, seriously, the linker will be so dramatic about it π
π DESCRIPTION π
gearman_worker_st is the whole vibe for a worker talking to the server. like, that's its entire job. π«Ά
gearman_worker_context() and gearman_worker_set_context() let you stash an arbitrary object for the user. whatever you want. it's your little pocket. π
gearman_worker_set_task_context_free_fn() sets a trigger that gets called when a gearman_task_st <#c.gearman_task_st> is released. so it's the lil cleanup cue, iykyk.
gearman_worker_timeout() and gearman_worker_set_timeout() get and set the current timeout value, in milliseconds, for the worker. milliseconds bestie, not seconds, do not play yourself π
gearman_worker_function_exist() is literally just used to figure out if a given worker has a specific function. yes/no. that's it. slay.
gearman_worker_work() has the worker just keep executing against jobs until an error occurs. it's giving main character energy that never clocks out. π₯
gearman_worker_grab_job() takes a job from one of the job servers. heads up: it is the responsibility of the caller to free the job once they're done β so don't just wander off. also, this interface is used in testing, and it is very rarely the correct interface to program against. like, genuinely. noted. π
normally malloc(3) and free(3) handle allocation and releasing workloads. if you wanna switch that up, gearman_worker_set_workload_malloc_fn() and gearman_worker_set_workload_free_fn() let you swap in your own custom functions. bespoke memory management, we love to see it. β¨
and if you need to remove a function from the server, you've got two options, pick your fighter:
gearman_worker_unregister_all()β removes all functions that the worker has told the gearmand server about.gearman_worker_unregister()β removes just a single function.
π RETURN π
Various. yeah. that's the whole thing. various. it's giving mystery, it's giving chaos, we move. π¦
π HOME π
wanna find out more? go check: <http://gearman.info/> β that's the spot. β
π 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, no cap π this lil guy was 1.1.21+ds, dated Feb 04, 2026, and it comes to you from the GEARMAN_WORKER_SET_CONTEXT(3) corner of the Gearmand manual. go set some context, periodt. π
π¦ 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