Development

Changeset 33307

You must first sign up to be able to contribute.

Changeset 33307

Show
Ignore:
Timestamp:
01/17/12 13:09:23 (1 year ago)
Author:
bicou
Message:

[sfGearmanPlugin] gearman based queue value as a static member of sfGearmanQueue instead of &$context mess

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfGearmanPlugin/trunk/lib/sfGearmanQueue.class.php

    r29482 r33307  
    1717   */ 
    1818  const PREFIX = 'queue.'; 
     19 
     20  /** 
     21   * last element retrieved 
     22   *  
     23   * @var mixed 
     24   */ 
     25  protected static $data = null; 
    1926 
    2027  /** 
     
    6269 
    6370    // attach function callback and receive queue message as context 
    64     $worker->addFunction(self::getFunctionName($queue), array(__CLASS__, 'work'), &$data); 
     71    $worker->addFunction(self::getFunctionName($queue), array(__CLASS__, 'work')); 
     72 
     73    // init worker data 
     74    self::$data = null; 
    6575 
    6676    // work the worker once only 
     
    6878 
    6979    // return worker data 
    70     return $data; 
     80    return self::$data; 
    7181  } 
    7282 
     
    7989   * @return boolean   always true 
    8090   */ 
    81   public static function work($job, $data = null
     91  public static function work($job
    8292  { 
    8393    // just unserialize workload 
    84     $data = unserialize($job->workload()); 
     94    self::$data = unserialize($job->workload()); 
    8595    return true; 
    8696  }