GEARMAN_CLIENT_SET_WORKLOAD_FREE_FN(3)

πŸ’… GEARMAN_CLIENT_SET_WORKLOAD_FREE_FN β€” bestie edition

okay so. we're in the Gearmand Documentation section of the manual (the whole thing lives at http://gearman.info/ btw 🫢), and today's topic is gearman_client_set_workload_free_fn β€” plus a whole lil friend group of related functions that all hang out in the same header. buckle up, it's giving very much "one page, many functions." ✨


🌸 SYNOPSIS 🌸

#include <libgearman/gearman.h>

type gearman_client_st

type gearman_task_context_free_fn

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)

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

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)
🚨 heads up bestie: both gearman_client_set_workload_malloc_fn and gearman_client_set_workload_free_fn are Deprecated since version 0.23 β€” use gearman_allocator_t instead. the vibes are "please stop using me" 😭

and when you compile, link with:

-lgearman

✨ DESCRIPTION ✨

so like, gearman_client_st is the whole personality of client <#term-client> communication with the server. it's the main character. πŸ‘‘

gearman_client_context() and gearman_client_set_context() let you stash an arbitrary object for the user β€” like a lil locker at the gym, except it's your own stuff and the library doesn't touch it. yk? πŸ™ˆ

gearman_client_set_task_context_free_fn() sets a trigger β€” a function that fires when a gearman_task_st gets released. think of it as the "clean up after yourself" bestie. πŸ§ΉπŸ’–

gearman_client_timeout() and gearman_client_set_timeout() get and set the current connection timeout value, in milliseconds, for the client. no cap, milliseconds. ⏱️

normally, malloc(3) and free(3) handle allocation and releasing of workloads. but gearman_client_set_workload_malloc_fn() and gearman_client_set_workload_free_fn() can swap those out for custom functions. however β€” these have been deprecated, so please, for the love of everything, look at gearman_allocator_t for the updated interface. it's the glow-up. πŸ’…

gearman_client_task_free_all() frees ALL current gearman_task_st that were created with the gearman_client_st. every single one. it's thorough like that. πŸ”₯

⚠️ Warning: if you call gearman_client_task_free_all(), you can end up with a SEGFAULT if you then try to use any gearman_task_st whose pointer you kept around. do NOT hold onto those pointers and then poke them. this is not a drill, this is literally undefined chaos. πŸ’€

πŸŽ€ RETURN VALUE πŸŽ€

gearman_client_timeout() returns an integer that represents how many milliseconds it'll wait for a connection before throwing an error. and if you see a value of -1, that means an infinite timeout value β€” no clock, just vibes, waiting forever. ⏳✨


🌈 HOME 🌈

for more info, please check: <http://gearman.info/>

See also:


πŸ‘‘ Author

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

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


that's the whole page bestie, ily, go write some slay client code πŸ«ΆπŸ’œ β€” this was version 1.1.21+ds, dated Feb 04, 20… (the year got a lil cut off, iconic behavior tbh), brought to you by the GEARMAN_CLIENT...ORKLOAD_FREE_FN(3) page. periodt. ✨

πŸ“¦ where this page comes from