Return Values

Examples

Example #1 Two tasks, one background and one not

This example illustrates the difference between running a background task
and a normal task. The client adds two tasks to execute the same function,
but one is added with addTaskBackground(). A callback is
set so that progress of the job can be tracked. A simple worker with an
artificial delay reports on the job progress and the client picks this up
through the callback. Two workers are run for this example. Note that the
background task does not show in the client output.

<?php

# The client script

# create our gearman client$gmc= new GearmanClient();

# add the default job server$gmc->addServer();

# set a couple of callbacks so we can track progress$gmc->setCompleteCallback("reverse_complete");$gmc->setStatusCallback("reverse_status");