GEARMAN_TASK_GIVE_WORKLOAD(3)

πŸ’– gearman_task_give_workload πŸ’–

okay bestie, this page lives in the Gearmand manual, third section (that's the library-calls girlies), and it's genuinely a whole vibe if you're into libgearman. and you ARE, because you're here. let's GO. ✨


πŸ“œ SYNOPSIS

first thing's first, you gotta pull in the header:

#include <libgearman/gearman.h>

then here's the whole cast of characters, all written out exactly the way the page says them:

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 gearman_task_numerator(const gearman_task_st *task)

uint32_t gearman_task_denominator(const gearman_task_st *task)

void gearman_task_give_workload(gearman_task_st *task, const void *workload, size_t workload_size)

size_t gearman_task_send_workload(gearman_task_st *task, const void *workload, size_t workload_size, gearman_return_t *ret_ptr)

const void *gearman_task_data(const gearman_task_st *task)

size_t gearman_task_data_size(const gearman_task_st *task)

void *gearman_task_take_data(gearman_task_st *task, size_t *data_size)

size_t gearman_task_recv_data(gearman_task_st *task, void *data, size_t data_size, gearman_return_t *ret_ptr)

const char *gearman_task_error(const gearman_task_st *task)

Added in version 0.21.

gearman_return_t gearman_task_return(const gearman_task_st *task)

Added in version 0.21.

and like, obviously, link it up:

-lgearman

πŸ¦‹ DESCRIPTION

so. a gearman_task_st is the way this library represents a task. the work that a client sends over to a gearman server? that's what we call a task, no cap. and a worker receives that task in the form of a job. the whole little family tree, iconic. πŸ‘‘

tasks (aka gearman_task_st) get born by calling one of these three:

  • gearman_execute()
  • gearman_client_add_task()
  • gearman_client_add_task_background()

gearman_client_add_task_status() can also create a gearman_task_st, and those ones are the surveillance tasks β€” they exist to monitor a gearman_task_st you made earlier. main character monitoring another main character, we love to see it. πŸ‘€

a quick tour of the functions, one by one:

  • gearman_task_free() β€” frees a task. you only actually gotta do this if the task was created with a preallocated structure, OR if you just wanna clean up the memory of one specific task. not every task needs it, so don't go freeing everything like a menace.
  • gearman_task_set_context() β€” sets the given context on the gearman_task_st. the context is basically your little messenger bag: you use it to pass information to a gearman_task_st.
  • gearman_task_context() β€” hands you back the context that was used when the gearman_task_st was created (or the one you set with gearman_task_set_context()).
  • gearman_task_data() β€” gives you the current data that's been returned to the task. and gearman_task_data_size() gives you the size of that value. gearman_task_take_data() does the same thing as gearman_task_data(), BUT the value it returns must be freed by the client with free(3). gearman_task_recv_data() is the one you reach for when you've got pre-allocated buffers.
  • gearman_task_is_known(), gearman_task_is_running(), gearman_task_numerator(), gearman_task_denominator() β€” these return values related to the last status update that was made to the gearman_task_st. and this is important bestie: they do NOT cause the gearman_task_st to update itself. they just report. no refreshing, no poking the server, nothing. periodt.
  • gearman_task_error() β€” returns the last error message that the gearman_task_st ran into. gearman_task_return() returns the last gearman_return_t that got stored. and if you see a value of GEARMAN_UNKNOWN_STATE, that means either the task hasn't been submitted to the server yet, OR no function was available if the job was submitted.

πŸŽ€ RETURN VALUE

honestly? various. it depends. 🀷

the one thing you cannot forget: any value returned by gearman_task_take_data() must have free(3) called on it. that's not optional, that's a promise you made. 🫢


🏠 HOME

wanna know more? go check out: 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 beauty shipped as version 1.1.21+ds, dated Feb 04, 2026, and it answers to the name GEARMAN_TASK_GIVE_WORKLOAD(3). go forth and give some workload. slay. πŸ’…βœ¨

πŸ“¦ where this page comes from