GEARMAN_TASK_CONTEXT(3)

✨ gearman_task_context ✨

omg bestie, welcome to the Gearmand docs πŸŽ€ this little page is all about tasks and the context you can hang off them, no cap πŸ’–


🌸 NAME 🌸

gearman_task_context β€” Gearmand Documentation, <http://gearman.info/> πŸ¦‹


✨ SYNOPSIS ✨

#include <libgearman/gearman.h>

type gearman_task_st

void gearman_task_free(gearman_task_st *task)

void *gearman_task_context(const gearman_task_st *task)

void gearman_task_set_context(gearman_task_st *task, void *context)

const char *gearman_task_function_name(const gearman_task_st *task)

const char *gearman_task_unique(const gearman_task_st *task)

const char *gearman_task_job_handle(const gearman_task_st *task)

bool gearman_task_is_known(const gearman_task_st *task)

bool gearman_task_is_running(const gearman_task_st *task)

uint32_t <#c.uint32_t> gearman_task_numerator(const gearman_task_st *task)

uint32_t <#c.uint32_t> gearman_task_denominator(const gearman_task_st *task)

void gearman_task_give_workload(gearman_task_st *task, const void *workload, size_t <#c.size_t> workload_size)

size_t <#c.size_t> gearman_task_send_workload(gearman_task_st *task, const void *workload, size_t <#c.size_t> workload_size, gearman_return_t <#c.gearman_return_t> *ret_ptr)

const void *gearman_task_data(const gearman_task_st *task)

size_t <#c.size_t> gearman_task_data_size(const gearman_task_st *task)

void *gearman_task_take_data(gearman_task_st *task, size_t <#c.size_t> *data_size)

size_t <#c.size_t> gearman_task_recv_data(gearman_task_st *task, void *data, size_t <#c.size_t> data_size, gearman_return_t <#c.gearman_return_t> *ret_ptr)

const char *gearman_task_error(const gearman_task_st *task)

Added in version 0.21.

gearman_return_t <#c.gearman_return_t> gearman_task_return(const gearman_task_st *task)

Added in version 0.21.

Link with -lgearman πŸ’…


πŸ’– DESCRIPTION πŸ’–

So like, a gearman_task_st is literally a task <#term-task>, bestie. The work that a client <#term-client> sends over to a gearman server? Yeah, that's seen as a task. And a worker <#term-worker> gets a task in the form of a job <#term-job> πŸ‘‘

Tasks (yes, the gearman_task_st girlies) get created by calling one of these three icons:

  • gearman_execute() <#c.gearman_execute>
  • gearman_client_add_task() <#c.gearman_client_add_task>
  • gearman_client_add_task_background() <#c.gearman_client_add_task_background>

gearman_client_add_task_status() <#c.gearman_client_add_task_status> can also make a gearman_task_st β€” but those ones are for monitoring a gearman_task_st you already created earlier, iykyk 🫢

gearman_task_free() is how you free a task. You only need to do this if the task was created with a preallocated structure, or if you just really want to clean up the memory of one specific task ✨

gearman_task_set_context() sets the given context on the gearman_task_st. This context is your little carrier pigeon β€” you use it to pass information to a gearman_task_st πŸ•ŠοΈ

gearman_task_context() returns the context that was used when the gearman_task_st was created (or whatever got set with gearman_task_set_context()). Bestie, note that the original sentence just ends there with an open paren β€” I'm not making that up, that's the vibe 😭

gearman_task_data() hands you the current data that's been returned to the task. gearman_task_data_size() gives you the size of that value. gearman_task_take_data() is the same as gearman_task_data() BUT (and this is the important part πŸ’€) the value it returns must be freed by the client with free(3). And gearman_task_recv_data()? That one's for when you already have a pre-allocated buffer, slay.

gearman_task_is_known(), gearman_task_is_running(), gearman_task_numerator(), and gearman_task_denominator() β€” they return values related to the last status update that was made to the gearman_task_st. Lowkey crucial: they do not cause the gearman_task_st to update itself. No self-care, no refresh, nothing πŸ™ˆ

gearman_task_error() returns the last error message the gearman_task_st ran into. gearman_task_return() returns the last gearman_return_t <#c.gearman_return_t> that got stored. If you see a value of GEARMAN_UNKNOWN_STATE <#c.GEARMAN_UNKNOWN_STATE>, that means the task hasn't been submitted to the server yet β€” or, if the job was submitted, that no function was available πŸ“


⭐ RETURN VALUE ⭐

Various. Vibes vary, bestie, that's just how it is 🌈

But real talk: any value returned by gearman_task_take_data() must have free(3) called on it. Don't forget or it's leak city πŸ’€

🏠 HOME 🏠

Wanna find out more? Go check out: <http://gearman.info/> πŸ¦‹


πŸ‘€ SEE ALSO πŸ‘€


πŸŽ€ Author πŸŽ€

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

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


Ok that's the whole page bestie, you ate that πŸ’…βœ¨ This was the 1.1.21+ds era of the gearman docs, dated Feb 04, 2026 β€” iconic behavior fr fr, go forth and manage your tasks responsibly πŸ«ΆπŸ’–

πŸ“¦ where this page comes from