Net_Gearman
[ class tree: Net_Gearman ] [ index: Net_Gearman ] [ all elements ]

Class: Net_Gearman_Set

Source Location: /Net_Gearman-0.1.0/Net/Gearman/Set.php

Class Overview


A class for creating sets of tasks


Author(s):

Copyright:

  • 2007-2008 Digg.com, Inc.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 68]
A class for creating sets of tasks

  1.  <?php
  2.  require_once 'Net/Gearman/Client.php';
  3.  
  4.  // This is the callback function for our tasks
  5.  function echoResult($result{
  6.      echo 'The result was: ' $result "\n";
  7.  }
  8.  
  9.  // Job name is the key, arguments to job are in the value array
  10.  $jobs = array(
  11.      'AddTwoNumbers' => array('1''2'),
  12.      'Multiply' => array('3''4')
  13.  );
  14.  
  15.  $set = new Net_Gearman_Set();
  16.  foreach ($jobs as $job => $args{
  17.      $task = new Net_Gearman_Task($job$args);
  18.      $task->attachCallback('echoResult');
  19.      $set->addTask($task);
  20.  }
  21.  
  22.  $client = new Net_Gearman_Client(array(
  23.      '127.0.0.1:7003''127.0.0.1:7004'
  24.  ));
  25.  
  26.  $client->runSet($set);
  27.  
  28.  ?>



[ Top ]


Class Variables

$callback =  null

[line 96]

Callback registered for set
  • Access: protected

Type:   mixed


[ Top ]

$handles = array()

[line 89]

Handle to task mapping
  • Access: public

Type:   array


[ Top ]

$tasks = array()

[line 82]

Tasks to run
  • Access: public

Type:   array


[ Top ]

$tasksCount =  0

[line 75]

Tasks count
  • Access: public

Type:   integer


[ Top ]



Method Detail

__construct (Constructor)   [line 106]

void __construct( [array $tasks = array()])

Constructor

Parameters:

array   $tasks   —  Array of tasks to run

[ Top ]

addTask   [line 121]

void addTask( Net_Gearman_Task $task)

Add a task to the set

Parameters:

object   $task   —  Task to add to the set

[ Top ]

attachCallback   [line 184]

void attachCallback( callback $callback)

Attach a callback to this set
  • Throws: Net_Gearman_Exception
  • Access: public

Parameters:

callback   $callback   —  A valid PHP callback

[ Top ]

current   [line 210]

int current( )

Return current position in tasks array

[ Top ]

finished   [line 159]

boolean finished( )

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.

  • Access: public

[ Top ]

getTask   [line 137]

object Instance getTask( string $handle)

Get a task
  • Return: of task
  • Throws: Net_Gearman_Exception
  • Access: public

Parameters:

string   $handle   —  Handle of task to get

[ Top ]

key   [line 221]

int key( )

Get the next key from tasks array

[ Top ]

next   [line 232]

mixed next( )

Advance the array pointer

[ Top ]

rewind   [line 199]

void rewind( )

Rewind the tasks array

[ Top ]

valid   [line 243]

boolean valid( )

Current position valid?

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:21:09 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.