Set.phpView Source

Show: PublicProtectedPrivateinherited
Table of Contents
Interface for Danga's Gearman job scheduling system

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

Package: ShSo\Net\Gearman
A class for creating sets of tasks

<?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

>VPropertyprotectedmixed $callback = null
Callback registered for set
Default valuenullDetails
Type
mixed
>VPropertypublicarray $handles = array()
Handle to task mapping
Default valuearray()Details
Type
array
>VPropertypublicarray $tasks = array()
Tasks to run
Default valuearray()Details
Type
array
>VPropertypublicinteger $tasksCount = 0
Tasks count
Default value0Details
Type
integer

Methods

methodpublic__construct(array $tasks = array()) : void

Constructor

Parameters
NameTypeDescription
$tasksarray

Array of tasks to run

Details
See
 
methodpublicaddTask(object $task) : void

Add a task to the set

Parameters
NameTypeDescription
$taskobject

Task to add to the set

Details
See
ShSo\Net\Gearman\Set::$tasks  
methodpublicattachCallback(callback $callback) : void

Attach a callback to this set

Parameters
NameTypeDescription
$callbackcallback

A valid PHP callback

Throws
ExceptionDescription
\ShSo\Net\Gearman\ShSo\Net\Gearman\Exception
methodpubliccount() : integer

Get the task count

Returns
TypeDescription
integerNumber of tasks in the set
Details
See
Countable::count()}  
methodpublicfinished() : boolean

Is 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.

Returns
TypeDescription
boolean
methodpublicgetIterator() : \ShSo\Net\Gearman\ArrayIterator

Get the iterator

Returns
TypeDescription
\ShSo\Net\Gearman\ArrayIteratorTasks
methodpublicgetTask(string $handle) : object

Get a task

Parameters
NameTypeDescription
$handlestring

Handle of task to get

Returns
TypeDescription
objectInstance of task
Throws
ExceptionDescription
\ShSo\Net\Gearman\ShSo\Net\Gearman\Exception
Documentation was generated by phpDocumentor 2.8.5.