# Create a function with a callback

## SYNOPSIS

#include <libgearman/gearman.h>

type gearman_worker_fn

gearman_return_t gearman_worker_add_function(gearman_worker_st *worker, const char *function_name, uint32_t timeout, gearman_worker_fn *function, void *context)

Compile and link with -lgearman

## DESCRIPTION

`gearman_worker_add_function()` adds function with a callback to a `gearman_worker_st` . A `gearman_job_st` is passed to the callback, it can be used to send messages to the client about the state of the work.

The context provided will only be shared with the function created.

To remove the function call `gearman_worker_unregister()`.

## RETURN VALUE

`gearman_worker_add_function()` returns a `gearman_return_t` with either `GEARMAN_SUCCESS`, or an error. Additional information on the error can be found with :c:function::gearman_worker_error

## HOME

To find out more information please check: http://gearman.info/

## SEE ALSO

gearmand(8) libgearman(3) gearman_worker_st(3)