当前位置: 首页>>代码示例>>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;未经允许,请勿转载。