當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。