本文整理汇总了PHP中Worker类的典型用法代码示例。如果您正苦于以下问题:PHP Worker类的具体用法?PHP Worker怎么用?PHP Worker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Worker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: getWorkerOptions
public static function getWorkerOptions()
{
return Worker::orderBy('id', 'desc')->lists('name', 'id');
}
开发者ID:rituzy,项目名称:iblog,代码行数:4,代码来源:Worker.php
示例14: deleteWorker
}
} else {
return true;
}
}
return $this->sqlError('E0060');
}
/**
* Delete existing worker from account
* @param account_id int User ID
* @param id int Worker ID
* @return bool
**/
public function deleteWorker($account_id, $id)
{
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("DELETE FROM {$this->table} WHERE account_id = ? AND id = ? LIMIT 1");
if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $account_id, $id) && $stmt->execute() && $stmt->affected_rows == 1) {
return true;
}
return $this->sqlError('E0061');
}
}
$worker = new Worker();
$worker->setDebug($debug);
$worker->setMysql($mysqli);
$worker->setMemcache($memcache);
$worker->setShare($share);
$worker->setConfig($config);
$worker->setUser($user);
$worker->setErrorCodes($aErrorCodes);
开发者ID:xisi,项目名称:mpos-fusion,代码行数:31,代码来源:worker.class.php
示例15: Worker
<?php
//require_once 'Autoloader.php';
require "Worker.php";
$ws_worker = new Worker("websocket://0.0.0.0:2346");
$http_worker->count = 4;
$ws_worker->onMessage = function ($connection, $data) {
// 向客户端发送hello $data
$connection->send('hello ' . $data);
};
Worker::runAll();
echo "cccccccccccccccccccccccc\n";
开发者ID:lisonglin0129,项目名称:LDFRAMEWORK,代码行数:12,代码来源:test.php
示例16: array
// reindex
$originWorkerListFlag = TRUE;
} else {
$workerList = array();
$workerList[0] = $worker;
// currentworker
$originWorkerFlag = TRUE;
}
} else {
// done this way as PARAM_LIST may be reused
$workerList = Worker::selectExpo($expo->expoid);
$originExpoFlag = TRUE;
}
} else {
// done this way as PARAM_LIST may be reused
$workerList = Worker::selectStation($station->stationid);
$originStationFlag = TRUE;
}
// this is the organizer get; need to finish with super/crew get
if ($author->isCrewMember()) {
// remove all workers
// remove Organizers if Station
// remove Supervisors if Expo
for ($k = 0; $k < count($workerList); $k--) {
$w = $workerList[$k];
if ($originStationFlag && $w->isSupervisor() || $originExpoFlag && $w->isOrganizer()) {
continue;
}
unset($workerList[$k]);
// remove in all other cases
}
开发者ID:ConSked,项目名称:scheduler,代码行数:31,代码来源:SendMessagePage.php
示例17: actionWorkers
function actionWorkers()
{
//$worker_model = new Worker;
$workers = Worker::model()->with('department', 'position')->findAll();
$this->render('workers', array('workers' => $workers));
}
开发者ID:vnilov,项目名称:delivery,代码行数:6,代码来源:WorkerController.php
示例18: set_name
class Person
{
private $name;
public function set_name($name)
{
$this->name = $name;
}
public function get_name()
{
return $this->name;
}
}
class Worker extends Person
{
private $salary;
public function set_salary($salary)
{
$this->salary = $salary;
}
public function get_salary()
{
return $this->salary;
}
}
$a_work = new Worker();
$a_work->set_name('Paul');
$a_work->set_salary(3500);
$name = $a_work->get_name();
$salary = $a_work->get_salary();
echo $name . "µÄÔÂнΪ" . $salary;
开发者ID:Crackpot,项目名称:gftop,代码行数:30,代码来源:14-3.php
示例19: editDuty
public function editDuty(Duty $duty)
{
$this->layout->title = 'Edit Duty';
$worker_opt = Worker::getWorkerOptions();
$this->layout->main = View::make('admin.dashboard')->nest('content', 'duties.edit', compact('duty', 'worker_opt'));
}
开发者ID:rituzy,项目名称:iblog,代码行数:6,代码来源:DutyController.php
示例20: 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
注:本文中的Worker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论