Set.php
PHP version 5.1.0+
LICENSE: This source file is subject to the New BSD license that is available through the world-wide-web at the following URI: http://www.opensource.org/licenses/bsd-license.php. If you did not receive a copy of the New BSD License and are unable to obtain it through the web, please send a note to license@php.net so we can mail you a copy immediately.
- Author
- Joe Stump
- Category
- Net
- Copyright
- 2007-2008 Digg.com, Inc.
- License
- New BSD License
- Link
- http://pear.php.net/package/Net_Gearman
- Link
- http://www.danga.com/gearman/
- Package
- ShSo\Net\Gearman
- Version
- CVS: $Id$
\ShSo\Net\Gearman\Set
<?php
require_once 'Net/Gearman/Client.php';
// This is the callback function for our tasks function echoResult($result) { echo 'The result was: ' . $result . "\n"; }
// Job name is the key, arguments to job are in the value array $jobs = array( 'AddTwoNumbers' => array('1', '2'), 'Multiply' => array('3', '4') );
$set = new ShSo\Net\Gearman\Set(); foreach ($jobs as $job => $args) { $task = new ShSo\Net\Gearman\Task($job, $args); $task->attachCallback('echoResult'); $set->addTask($task); }
$client = new ShSo\Net\Gearman\Client(array( '127.0.0.1:7003', '127.0.0.1:7004' ));
$client->runSet($set);
?>
- Implements
- See
- ShSo\Net\Gearman\Worker
- Author
- Joe Stump
- Category
- Net
- Copyright
- 2007-2008 Digg.com, Inc.
- License
- New BSD License
- Link
- http://www.danga.com/gearman/
- Version
- Release: @package_version@
Properties
Methods

addTask(object $task) : voidAdd a task to the set
| Name | Type | Description |
|---|---|---|
| $task | object | Task to add to the set |

attachCallback(callback $callback) : voidAttach a callback to this set
| Name | Type | Description |
|---|---|---|
| $callback | callback | A valid PHP callback |
| Exception | Description |
|---|---|
| \ShSo\Net\Gearman\ShSo\Net\Gearman\Exception |

finished() : booleanIs this set finished running?
This function will return true if all of the tasks in the set have finished running. If they have we also run the set callbacks if there is one.
| Type | Description |
|---|---|
| boolean |

getIterator() : \ShSo\Net\Gearman\ArrayIteratorGet the iterator
| Type | Description |
|---|---|
| \ShSo\Net\Gearman\ArrayIterator | Tasks |