當前位置: 首頁>>代碼示例>>PHP>>正文


PHP GearmanClient::setCreatedCallback方法代碼示例

本文整理匯總了PHP中GearmanClient::setCreatedCallback方法的典型用法代碼示例。如果您正苦於以下問題:PHP GearmanClient::setCreatedCallback方法的具體用法?PHP GearmanClient::setCreatedCallback怎麽用?PHP GearmanClient::setCreatedCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GearmanClient的用法示例。


在下文中一共展示了GearmanClient::setCreatedCallback方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: assignTaskCallbacks

 /**
  * Assign all GearmanClient callbacks as Symfony2 events
  *
  * @param \GearmanClient $gearmanClient Gearman client
  *
  * @return GearmanCallbacksDispatcher self Object
  */
 public function assignTaskCallbacks(\GearmanClient $gearmanClient)
 {
     $gearmanClient->setCompleteCallback(array($this, 'assignCompleteCallback'));
     $gearmanClient->setFailCallback(array($this, 'assignFailCallback'));
     $gearmanClient->setDataCallback(array($this, 'assignDataCallback'));
     $gearmanClient->setCreatedCallback(array($this, 'assignCreatedCallback'));
     $gearmanClient->setExceptionCallback(array($this, 'assignExceptionCallback'));
     $gearmanClient->setStatusCallback(array($this, 'assignStatusCallback'));
     $gearmanClient->setWarningCallback(array($this, 'assignWarningCallback'));
     $gearmanClient->setWorkloadCallback(array($this, 'assignWorkloadCallback'));
 }
開發者ID:eduardtrandafir,項目名稱:gearman-bundle,代碼行數:18,代碼來源:GearmanCallbacksDispatcher.php

示例2: GearmanClient

/*
 * Gearman PHP Extension
 *
 * Copyright (C) 2008 James M. Luedke (jluedke@jamesluedke.com)
 *                           Eric Day (eday@oddments.org)
 * All rights reserved.
 *
 * Use and distribution licensed under the PHP license.  See
 * the LICENSE file in this directory for full text.
 */
/* create our object */
$gmc = new GearmanClient();
/* add the default server */
$gmc->addServer();
/* set a few callbacks */
$gmc->setCreatedCallback("thumb_created");
$gmc->setCompleteCallback("thumb_complete");
$gmc->setFailCallback("thumb_fail");
for ($x = 0; $x < 20; $x++) {
    $data[$x]['src'] = $_SERVER['argv'][1];
    $data[$x]['dest'] = "{$x}.jpg";
    $data[$x]['x'] = (80 + 1) * ($x + 1);
    $data[$x]['y'] = NULL;
}
/* fire off each job */
foreach ($data as $img) {
    /* NOTE: if you want to asynchronously queue jobs use
     ** $task= $gmc->add_task_background("shrink_image", serialize($img));
     ** however keep in mind that your complete callback will not get called */
    if (!$gmc->addTask("shrink_image", serialize($img))) {
        echo "ERROR RET: " . $gmc->error() . "\n";
開發者ID:Sean-Der,項目名稱:pecl-gearman,代碼行數:31,代碼來源:image_thumbnail_client_task.php

示例3: reverse_created

<?php

$gmc = new GearmanClient();
$gmc->addServer();
$gmc->setCreatedCallback("reverse_created");
$gmc->setStatusCallback("reverse_status");
$gmc->setCompleteCallback("reverse_complete");
$gmc->setFailCallback("reverse_fail");
$task = $gmc->addTask("reverse", "this is a test", NULL);
if (!$gmc->runTasks()) {
    echo "ERROR " . $gmc->error() . "\n";
    exit;
}
echo "DONE\n";
function reverse_created($task)
{
    echo "CREATED: " . $task->jobHandle() . "\n";
}
function reverse_status($task)
{
    echo "STATUS: " . $task->jobHandle() . " - " . $task->taskNumerator() . "/" . $task->taskDenominator() . "\n";
}
function reverse_complete($task)
{
    echo "COMPLETE: " . $task->jobHandle() . "\n";
}
function reverse_fail($task)
{
    echo "FAILED: " . $task->jobHandle() . "\n";
}
開發者ID:Sean-Der,項目名稱:pecl-gearman,代碼行數:30,代碼來源:reverse_client_task.php


注:本文中的GearmanClient::setCreatedCallback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。