svn: /phpdoc/en/trunk/reference/gearman/gearmanclient/ addtask.xml
| From: | Sherif Ramadan | Date: | Fri, 05 Apr 2013 19:09:32 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/gearman/gearmanclient/ addtask.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-11171@lists.php.net to get a copy of this message | ||
googleguy Fri, 05 Apr 2013 19:09:32 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=330011
Log:
Fix GearmanClient::addTask() example code.
Callback needs to be set before GearmanClient::addTask() is called.
Patch by Blake Gardner
Changed paths:
U phpdoc/en/trunk/reference/gearman/gearmanclient/addtask.xml
Modified: phpdoc/en/trunk/reference/gearman/gearmanclient/addtask.xml
===================================================================
--- phpdoc/en/trunk/reference/gearman/gearmanclient/addtask.xml 2013-04-05 13:04:48 UTC (rev 330010)
+++ phpdoc/en/trunk/reference/gearman/gearmanclient/addtask.xml 2013-04-05 19:09:32 UTC (rev 330011)
@@ -86,15 +86,15 @@
# add the default job server
$gmclient->addServer();
+# set a function to be called when the work is complete
+$gmclient->setCompleteCallback("complete");
+
# add a task to perform the "reverse" function on the string "Hello World!"
$gmclient->addTask("reverse", "Hello World!", null, "1");
# add another task to perform the "reverse" function on the string "!dlroW
olleH"
$gmclient->addTask("reverse", "!dlroW olleH", null, "2");
-# set a function to be called when the work is complete
-$gmclient->setCompleteCallback("complete");
-
# run the tasks
$gmclient->runTasks();
@@ -123,12 +123,14 @@
$client = new GearmanClient();
$client->addServer();
+# set a function to be called when the work is complete
+$client->setCompleteCallback("reverse_complete");
+
# Add some tasks for a placeholder of where to put the results
$results = array();
$client->addTask("reverse", "Hello World!", &$results, "t1");
$client->addTask("reverse", "!dlroW olleH", &$results, "t2");
-$client->setCompleteCallback("reverse_complete");
$client->runTasks();
# The results should now be filled in from the callbacks