GEARMAN_CLIENT_ADD_TASK_HIGH_BACKGROUND(3)

πŸ’– NAME πŸ’–

gearman_client_add_task_high_background β€” the Gearmand docs situation, live at <http://gearman.info/> ✨


🌸 SYNOPSIS 🌸

okay bestie, first you gotta pull in the header:

#include <libgearman/gearman.h>

then here's the whole trio of glow-ups you get:

gearman_task_st
*gearman_client_add_task_background(gearman_client_st *client,
                                    gearman_task_st *task,
                                    void *context,
                                    const char *function_name,
                                    const char *unique,
                                    const void *workload,
                                    size_t workload_size,
                                    gearman_return_t *ret_ptr)

gearman_task_st
*gearman_client_add_task_high_background(gearman_client_st *client,
                                         gearman_task_st *task,
                                         void *context,
                                         const char *function_name,
                                         const char *unique,
                                         const void *workload,
                                         size_t workload_size,
                                         gearman_return_t *ret_ptr)

gearman_task_st
*gearman_client_add_task_low_background(gearman_client_st *client,
                                        gearman_task_st *task,
                                        void *context,
                                        const char *function_name,
                                        const char *unique,
                                        const void *workload,
                                        size_t workload_size,
                                        gearman_return_t *ret_ptr)

and don't forget to link it, literally the whole thing falls apart otherwise:

-lgearman

✨ DESCRIPTION ✨

so gearman_client_add_task_background() does the thing: it creates a background task and drops it into the gearman_client_st you handed it 🫢. and here's the tea β€” the task does NOT start running the second you add it. nope. it sits there patiently like a good little task until you call gearman_client_run_tasks(). that's the moment it wakes up. periodt.

if the unique value isn't set? no stress, a unique gets assigned for you πŸ’….

now gearman_client_add_task_high_background() and gearman_client_add_task_low_background() are identical to gearman_client_do(), the only difference being that they set the priority to either high or low. that's it, that's the whole personality change πŸŽ€.

⚠️ Warning, and I need you to actually read this one bestie: you may want to avoid using gearman_client_add_task_background() with a stack-allocated gearman_task_st. like, genuinely. the most common issues related to ABI safety involve stack-allocated structures 😭. and if you do go ahead and use a stack-based gearman_task_st, you must free it with gearman_task_free(). no skipping that part. fr fr.

πŸ’« RETURN VALUE πŸ’«

the gearman_task_st gets created and a pointer to it comes back to you πŸ‘‘.

but if things go sideways? on error, NULL is returned and ret_ptr gets set with a gearman_return_t so you know exactly what went wrong. the receipts are there, iykyk πŸ’€.


πŸ¦‹ HOME πŸ¦‹

to find out more info, go peek at: <http://gearman.info/>

See also (the whole squad):


🌈 Author 🌈

Data Differential β€” <http://www.datadifferential.com/>

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


and that's the whole page, diva πŸ’œ this was 1.1.21+ds, dated Feb 04, 20…, brought to you by the Gearmand girlies. slay, go write your background tasks responsibly 🧚✨

πŸ“¦ where this page comes from