当前位置: 首页>>代码示例>>PHP>>正文


PHP Worker类代码示例

本文整理汇总了PHP中Worker的典型用法代码示例。如果您正苦于以下问题:PHP Worker类的具体用法?PHP Worker怎么用?PHP Worker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Worker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _startWorker

 /**
  * Start a worker
  */
 protected function _startWorker()
 {
     $worker = new Worker();
     $worker->logLevel = $this->logLevel;
     fwrite(STDOUT, '*** Starting scheduler worker ' . PHP_EOL);
     $worker->work($this->interval);
 }
开发者ID:craryprimitiveman,项目名称:php-resque-scheduler,代码行数:10,代码来源:InitTrait.php

示例2: addWorker

 /**
  * Adds a worker to the action.
  *
  * @param Worker $worker
  *
  * @return Action
  * @throws \Exception
  */
 public function addWorker($worker)
 {
     if (!$worker instanceof Worker) {
         throw new \Exception('$worker is not an instance of Worker');
     }
     $this->workerList[$worker->getId()] = $worker;
     return $this;
 }
开发者ID:olivier1980,项目名称:alpharpc,代码行数:16,代码来源:Action.php

示例3: testGetStacked

 public function testGetStacked()
 {
     $worker = new Worker();
     $work = new WorkerTestWork();
     $worker->stack($work);
     $this->assertEquals(1, $worker->getStacked());
     $worker->stack($work);
     $this->assertEquals(2, $worker->getStacked());
 }
开发者ID:krakjoe,项目名称:pthreads-polyfill,代码行数:9,代码来源:WorkerTest.php

示例4: testWorkerNoJobs

 /**
  * When the timeout passed to ::processOne() is 0 and there are no jobs it should return quitely.
  * @throws Exception\WorkerException
  */
 public function testWorkerNoJobs()
 {
     $testWorkerRuns = $this;
     $tube = 'worker_tube_' . rand(53, 504);
     $data = 'worker_value_' . rand(95, 3000);
     $pheanstalk = new Pheanstalk(self::SERVER_HOST, self::SERVER_PORT);
     $worker = new Worker(self::SERVER_HOST, self::SERVER_PORT);
     $worker->register($tube, function (Job $job) use($testWorkerRuns, $data) {
         $testWorkerRuns->assertEquals($data, $job->getData());
     });
     $processedJob = $worker->processOne(0);
     $stats = $pheanstalk->statsTube($tube);
     $this->assertEquals($stats['total-jobs'], 0);
 }
开发者ID:koenpunt,项目名称:pheanstalk-worker,代码行数:18,代码来源:WorkerTest.php

示例5: startWorkers

 private function startWorkers()
 {
     $wrapper = realpath(__DIR__ . '/../../../../bin/phpunit-wrapper');
     for ($i = 1; $i <= $this->options->processes; $i++) {
         $worker = new Worker();
         if ($this->options->noTestTokens) {
             $token = null;
         } else {
             $token = $i;
         }
         $worker->start($wrapper, $token);
         $this->streams[] = $worker->stdout();
         $this->workers[] = $worker;
     }
 }
开发者ID:jrijnaars,项目名称:PHP-project,代码行数:15,代码来源:WrapperRunner.php

示例6: testWorkerGc

 public function testWorkerGc()
 {
     $worker = new Worker();
     $work = new WorkerTestWork();
     $worker->start();
     $worker->stack($work);
     $work->synchronized(function ($work) {
         if (!$work->isGarbage()) {
             $work->wait();
         }
     }, $work);
     $this->assertEquals($worker->collect(function ($task) {
         return false;
     }), 1);
     $this->assertEquals($worker->collect(function ($task) {
         return $task->isGarbage();
     }), 0);
 }
开发者ID:stof,项目名称:pthreads-polyfill,代码行数:18,代码来源:WorkerTest.php

示例7: server

 {
     echo $user->getUsername();
 }
 public function server()
 {
     $ws_worker = new \Worker("websocket://0.0.0.0:2346");
     $ws_worker->count = 4;
     $ws_worker->onMessage = function ($connection, $data) {
         $connection->send('hello ' . $data);
     };
开发者ID:lisonglin0129,项目名称:LDFRAMEWORK,代码行数:10,代码来源:IndexAction.class.php

示例8: saveWorker

 /**
  * Save or update worker
  * @param Worker $worker
  * @return Worker
  */
 public function saveWorker(Worker $worker)
 {
     if (is_null($worker->getId())) {
         $query = $this->db->prepare("INSERT INTO workers (host, port, type, status) VALUES (?, ?, ?, ?)");
         $query->execute([$worker->getHost(), $worker->getPort(), $worker->getType(), $worker->getStatus()]);
         $worker->setId($this->db->lastInsertId());
     } else {
         $query = $this->db->prepare("UPDATE workers SET host = ?, port = ?, type = ?, status = ? WHERE id = ?");
         $query->execute([$worker->getHost(), $worker->getPort(), $worker->getType(), $worker->getStatus(), $worker->getId()]);
     }
     return $worker;
 }
开发者ID:andrazk,项目名称:queue_manager,代码行数:17,代码来源:SqlStorage.php

示例9: fillData

 public function fillData(ShiftAssignmentView $shiftassignment)
 {
     $this->workerid = $shiftassignment->workerid;
     $this->stationid = $shiftassignment->stationid;
     $this->expoid = $shiftassignment->expoid;
     $this->expo = $shiftassignment->expoTitle;
     $this->station = $shiftassignment->location . " (" . $shiftassignment->stationTitle . ")";
     $this->startTime = $shiftassignment->startTime;
     $this->stopTime = $shiftassignment->stopTime;
     $worker = Worker::selectID($shiftassignment->workerid);
     $this->workerName = $worker->nameString2();
     $this->workerEmail = $worker->email;
     return $this;
 }
开发者ID:ConSked,项目名称:scheduler,代码行数:14,代码来源:MessageData.php

示例10: createShiftCheckInHTMLList

function createShiftCheckInHTMLList($expoid, $stationid)
{
    echo "<div id=\"workerlist_table\">\n";
    echo "<form method=\"POST\" name=\"ShiftCheckIn_form\" action=\"ShiftCheckInAction.php?" . PARAM_LIST_INDEX . "=" . $stationid . "\">\n";
    echo "<table>\n";
    $shiftAssignmentList = ShiftAssignmentView::selectStation($expoid, $stationid);
    $c = count($shiftAssignmentList);
    $workerList = array();
    for ($k = 0; $k < $c; $k++) {
        $workerList[$k] = Worker::selectID($shiftAssignmentList[$k]->workerid);
    }
    usort($workerList, "WorkerCompare");
    echo "<tr><td class=\"rowTitle\" colspan=\"4\">Supervisors</td></tr>\n";
    $supervisors = 0;
    for ($k = 0; $k < $c; $k++) {
        if ($workerList[$k]->isSupervisor() && !$workerList[$k]->isDisabled) {
            $ss = ShiftStatus::mostRecentStatus($workerList[$k]->workerid, $stationid, $expoid);
            if (count($ss) > 0) {
                $statusType = $ss->statusType;
            } else {
                $statusType = NULL;
            }
            makeShiftCheckInListHTMLRows($workerList[$k], $statusType);
            $supervisors++;
        }
    }
    if ($supervisors == 0) {
        echo "<tr><td class=\"fieldError\" colspan=\"4\">There are currently no Supervisors assigned to this station.</td></tr>\n";
    }
    echo "<tr><td class=\"rowTitle\" colspan=\"4\">Crew</td></tr>\n";
    $crew = 0;
    for ($k = 0; $k < $c; $k++) {
        if ($workerList[$k]->isCrewMember() && !$workerList[$k]->isDisabled) {
            $ss = ShiftStatus::mostRecentStatus($workerList[$k]->workerid, $stationid, $expoid);
            if (count($ss) > 0) {
                $statusType = $ss->statusType;
            } else {
                $statusType = NULL;
            }
            makeShiftCheckInListHTMLRows($workerList[$k], $statusType);
            $crew++;
        }
    }
    // $k
    if ($crew == 0) {
        echo "<tr><td class=\"fieldError\" colspan=\"4\">There are currently no Crew assigned to this station.</td></tr>\n";
    }
    echo "</table></form></div><!-- workerlist_table -->\n";
}
开发者ID:ConSked,项目名称:scheduler,代码行数:49,代码来源:ShiftCheckInList.php

示例11: postRelated

 /**
  * Show the form for creating a new resource.
  * @param Request $request
  * @return Response
  */
 public function postRelated(Request $request)
 {
     $people = People::all();
     $worker = Worker::all();
     $ids = array();
     for ($i = 0; $i < $worker->count(); $i++) {
         for ($j = 0; $j < $people->count(); $j++) {
             if ($people->get($j)->id == $worker->get($i)->people_id) {
                 $ids[] = $people->get($j)->id;
             }
         }
     }
     $people = People::whereNotIn('id', $ids)->get();
     $branch = Branch::findOrFail($request->get('id'));
     return view('admin.listpeople', compact('people', 'branch'));
 }
开发者ID:EstebanJesus,项目名称:bancopedagogico-v2,代码行数:21,代码来源:PeopleTraits.php

示例12: searchWorkers

 /**
  * Поиск сотрудников
  * @param  string $query
  * @param  integer $limit
  * @return \Elasticquent\ElasticquentResultCollection
  */
 public function searchWorkers(string $query, int $limit = 10)
 {
     return Worker::searchByQuery(['match' => ['search' => ['query' => $query, 'operator' => 'and']]], null, null, $limit)->load('organization');
     //    $result = Worker::searchByQuery(
     //      ['match' => [
     //        'search' => [
     //          'query' => $query,
     //          'operator' => 'and',
     //        ]
     //      ]],
     //
     //      ['orgs' => [
     //        'terms' => [
     //          'field' => 'organization_id',
     //          'size' => 10
     //        ],
     //        'aggregations' => [
     //          'fio' => [
     //            'terms' => [
     //              'field' => 'fio',
     //            ],
     //            'aggregations' => [
     //              'top' => [
     //                'top_hits' => [
     //                  'size' => 1
     //                ]
     //              ]
     //            ]
     //          ]
     //        ]
     //      ]], null, 0
     //    );
     //
     //    $ids = [];
     //    $aggregations = $result->getAggregations();
     //    foreach($aggregations['orgs']['buckets'] as $data) {
     //      foreach($data['fio']['buckets'] as $data2) {
     //        $ids[] = $data2['top']['hits']['hits'][0]['_id'];
     //      }
     //    }
     //    $ids = array_slice($ids, 0, 20);
     //
     //    return Worker::whereIn('id', $ids)->with('organization')->get();
 }
开发者ID:w1lliams,项目名称:sh,代码行数:50,代码来源:Search.php

示例13: start

 public function start($options = PTHREADS_INHERIT_ALL)
 {
     ThreadManager::getInstance()->add($this);
     if (!$this->isRunning() and !$this->isJoined() and !$this->isTerminated() and !$this->isShutdown()) {
         return parent::start($options);
     }
     return false;
 }
开发者ID:hlogeon,项目名称:PocketMineJs-MP,代码行数:8,代码来源:Worker.php

示例14:

 function __construct($config)
 {
     parent::__construct($config);
     $this->register_handler("do_get_testsyncphp_thing_v1");
     $this->register_handler("do_put_testsyncphp_thing_v1");
     $this->register_handler("do_post_testsyncphp_thing_v1");
     $this->register_handler("do_delete_testsyncphp_thing_v1");
 }
开发者ID:wqx081,项目名称:gearbox,代码行数:8,代码来源:workerTestSync.php

示例15: release

 protected function release()
 {
     if (count($this->sqlArray) > 0) {
         $this->executeSql();
     }
     parent::release();
     // TODO: Change the autogenerated stub
 }
开发者ID:highestgoodlikewater,项目名称:yii2-liuxy-extension,代码行数:8,代码来源:AsyncSqlWorker.php


注:本文中的Worker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。