GEARMAN_CLIENT_CONTEXT(3)

πŸ’– GEARMAN_CLIENT_CONTEXT πŸ’–

okay bestie, gather round, because this is the gearmand documentation situation and we're doing it together. Like, this is the manual page for gearman_client_context, and yes it's giving very much "library internals" but honestly? kinda iconic. let's go. πŸ¦‹


✨ NAME ✨

gearman_client_context β€” Gearmand Documentation, the whole vibe lives at <http://gearman.info/> πŸŽ€


🌸 SYNOPSIS 🌸

first things first, you gotta pull in the header, no cap:

#include <libgearman/gearman.h>

then we've got the types, the ✨ core cast ✨ of this whole drama:

type gearman_client_st

type gearman_task_context_free_fn

and now the functions, one by one, no skips, no shortcuts:

int gearman_client_timeout(gearman_client_st *client)

void gearman_client_set_timeout(gearman_client_st *client, int timeout)

void *gearman_client_context(const gearman_client_st *client)

void gearman_client_set_context(gearman_client_st *client, void *context)

void gearman_client_set_workload_malloc_fn(gearman_client_st *client,
        gearman_malloc_fn *function, void *context)

Deprecated since version 0.23: Use gearman_allocator_t

void gearman_client_set_workload_free_fn(gearman_client_st *client,
        gearman_free_fn *function, void *context)

Deprecated since version 0.23: Use gearman_allocator_t

void gearman_client_task_free_all(gearman_client_st *client)

void gearman_client_set_task_context_free_fn(gearman_client_st *client,
        gearman_task_context_free_fn *function)

and when you build, you link with -lgearman, that's the whole thing πŸ’…

ngl notice how gearman_client_set_workload_malloc_fn() and gearman_client_set_workload_free_fn() are deprecated since version 0.23 β€” for both of them, the move is gearman_allocator_t instead. the old interface is still there but it's giving "we've moved on". 🫢

πŸ’œ DESCRIPTION πŸ’œ

so gearman_client_st is the whole reason we're here β€” it's what you use for client communication with the server. that's the job. that's the assignment. slay. ✨

gearman_client_context() and gearman_client_set_context() are your little storage cubbies β€” they let you stash an arbitrary object for the user. literally whatever you want in there, that's between you and your code. πŸŽ€

gearman_client_set_task_context_free_fn() sets up a trigger that gets called when a gearman_task_st is released. so like, a callback for the moment the task says bye. πŸ¦‹

gearman_client_timeout() and gearman_client_set_timeout() get and set the current connection timeout value, in milliseconds, for the client. get it, set it, that's the dynamic duo. 🌸

now, normally malloc(3) and free(3) handle allocating and releasing workloads. gearman_client_set_workload_malloc_fn() and gearman_client_set_workload_free_fn() exist so you can swap those out for your own custom functions. but β€” and this is the important part, bestie β€” those two have been deprecated, so please go look at gearman_allocator_t for the updated interface. do not skip that part. πŸ™ˆ

gearman_client_task_free_all() frees all the current gearman_task_st that have been created with the gearman_client_st. all of them. every last one. ⭐

Warning: ⚠️ if you call gearman_client_task_free_all(), you can end up with a SEGFAULT if you try to use any gearman_task_st that you've kept pointers to. like, they're freed now. the pointers are stale. touching them is a bad time. this is not a drill, this is the flirty little footnote that will ruin your whole afternoon. πŸ’€

🌈 RETURN VALUE 🌈

gearman_client_timeout() returns an integer, and that integer represents the amount of time in milliseconds to wait for a connection before throwing an error. ⏳

and get this β€” a value of -1 means an infinite timeout value. forever. no clock. main character energy fr fr. πŸ‘‘


πŸ’– HOME πŸ’–

to find out more information please check: <http://gearman.info/>

See also:

like, go read those too, they're all part of the same friend group 🫢


πŸŽ€ Author πŸŽ€

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

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


and that's the whole page, bestie!! you understood it, you ate, no crumbs. πŸ’…βœ¨

this was version 1.1.21+ds, dated Feb 04, 2026, and it lives under the name GEARMAN_CLIENT_CONTEXT(3) so you can find it again whenever you need it. mwah. πŸ“πŸ§š

πŸ“¦ where this page comes from