本文整理汇总了PHP中msg_receive函数的典型用法代码示例。如果您正苦于以下问题:PHP msg_receive函数的具体用法?PHP msg_receive怎么用?PHP msg_receive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了msg_receive函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: readQueuedIssues
/**
*
*/
public function readQueuedIssues()
{
// Read the entire queue and write all issues to the
// base collector
// Get the status of the queue
$status = msg_stat_queue($this->message_queue_resource);
// Read messages while there are still messages on
// the queue
while ($status['msg_qnum'] > 0) {
$message = null;
$message_type = 0;
// Receive the message, populating $message by
// reference
if (false !== msg_receive($this->message_queue_resource, self::MESSAGE_TYPE_ISSUE, $message_type, 2048, $message, true)) {
assert($message instanceof IssueInstance, "Messages must be of type IssueInstance.");
// Cast the message to an IssueInstance
if ($message instanceof IssueInstance) {
$this->collectIssue($message);
}
} else {
break;
}
$status = msg_stat_queue($this->message_queue_resource);
}
}
开发者ID:nagyistge,项目名称:phan,代码行数:28,代码来源:ParallelParentCollector.php
示例2: receive
/**
* Waits for and receives a message
* @param integer $type
* @return mixed
*/
public function receive($type)
{
$rcvType = 0;
$msg = '';
msg_receive($this->queue, $type, $rcvType, $this->size, $msg);
return $msg;
}
开发者ID:shitfSign,项目名称:threads,代码行数:12,代码来源:Queue.php
示例3: actionDequeue
public function actionDequeue($qId, $data)
{
$q = msg_get_queue($qId);
$r = msg_receive($q, 1, $msgType, 10000, $msg);
echo "Result: " . $r . "<br/>";
echo " Got msg: " . $msg;
}
开发者ID:Clarence-pan,项目名称:test,代码行数:7,代码来源:TestMessageQueueController.php
示例4: pop
/**
* {@inheritdoc}
*/
public function pop()
{
if (!msg_receive($this->getQueue(), -time(), $eta, $this->itemMaxLength, $item, $this->serialize, MSG_IPC_NOWAIT, $errorCode)) {
throw MSG_ENOMSG === $errorCode ? new NoItemAvailableException($this) : new QueueException($this, self::getErrorMessage($errorCode), $errorCode);
}
return $item;
}
开发者ID:rybakit,项目名称:phive-queue,代码行数:10,代码来源:SysVQueue.php
示例5: peek
function peek()
{
$this->init();
$flags = $this->blocking && !$this->blockingTimeout ? 0 : MSG_IPC_NOWAIT;
if (!$this->blockingTimeout || !$this->blocking) {
msg_receive($this->seg, 1, $msgtype, $this->maxMsgSize, $message, false, $flags, $errno);
} else {
$timeout = new Scalr_Util_Timeout($this->blockingTimeout);
try {
while (!$message && !$timeout->reached()) {
if (!msg_receive($this->seg, 1, $msgtype, $this->maxMsgSize, $message, false, $flags, $errno)) {
$timeout->sleep(10);
}
}
} catch (Scalr_Util_TimeoutException $e) {
return null;
}
}
if ($message) {
return unserialize($message);
} else {
if ($errno == MSG_ENOMSG && !$this->blocking) {
return null;
}
if ($errno == 22) {
return null;
}
throw new Scalr_System_Ipc_Exception($errno ? self::$msgrcv_errors[$errno] : "Cannot receive message", $errno);
}
}
开发者ID:rakesh-mohanta,项目名称:scalr,代码行数:30,代码来源:ShmQueue.php
示例6: collectFiles
/**
* 从消息队列中获取要监控的文件列表
* @param bool $block
* @return void
*/
protected function collectFiles($block = false)
{
$msg_type = $message = null;
$flag = $block ? 0 : MSG_IPC_NOWAIT;
if (@msg_receive(\Man\Core\Master::getQueueId(), self::MSG_TYPE_FILE_MONITOR, $msg_type, 10000, $message, true, $flag)) {
// 被排除的路径
$exclude_path = array();
// 因为配置可能会被更改,所以每次都会重新从配置中查找排除路径
$config_exclude_path = $this->getExcludeFiles();
foreach ($config_exclude_path as $path) {
if ($real_path = realpath($path)) {
$exclude_path[] = $real_path;
}
}
foreach ($message as $file) {
$is_exclude_file = false;
foreach ($exclude_path as $path) {
// 是被排除的文件
if (0 === strpos($file, $path)) {
$is_exclude_file = true;
break;
}
}
if (!$is_exclude_file && !isset($this->filesToInotify[$file])) {
$stat = @stat($file);
$mtime = isset($stat['mtime']) ? $stat['mtime'] : 0;
$this->filesToInotify[$file] = $mtime;
}
}
}
}
开发者ID:noikiy,项目名称:workerman-flappy-bird,代码行数:36,代码来源:FileMonitor.php
示例7: mqRead
static function mqRead($name, $want = 0, $wait = true)
{
$mq = msg_get_queue(self::_ftok($name));
$type = null;
// Recieved Message Type
$size = 8192;
// Max Message Size
$mess = null;
// Recieved Message Data
$unser = true;
$flags = 0;
$error = null;
if ($wait == false) {
$flags |= MSG_IPC_NOWAIT;
}
if (msg_receive($mq, $want, $type, $size, $mess, $unser, $flags, $error)) {
return $mess;
}
Radix::dump($mq);
Radix::dump($want);
Radix::dump($type);
Radix::dump($size);
Radix::dump($mess);
Radix::dump($unser);
Radix::dump($flags);
Radix::dump($error);
exit;
}
开发者ID:edoceo,项目名称:radix,代码行数:28,代码来源:IPC.php
示例8: process
private function process()
{
$messageType = NULL;
$messageMaxSize = 1024;
while (TRUE) {
if (count($this->childs) < $this->max) {
echo count($this->childs) . " ";
if (msg_receive($this->queue, QUEUE_TYPE_START, $messageType, $messageMaxSize, $this->message)) {
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork' . PHP_EOL);
} else {
if ($pid) {
$this->childs[$pid] = TRUE;
$messageType = NULL;
$this->message = NULL;
} else {
sleep(3);
$this->complete($messageType, $this->message);
exit;
}
}
foreach ($this->childs as $pid => $value) {
if (pcntl_waitpid($pid, $status, WNOHANG)) {
if (pcntl_wifexited($status)) {
unset($this->childs[$pid]);
}
}
}
}
}
sleep(1);
}
}
开发者ID:sergeypavlenko,项目名称:queue,代码行数:34,代码来源:worker.php
示例9: pickup
public function pickup()
{
if (msg_receive($this->queue, $this->msgtype_receive, $msgtype_erhalten, $this->maxsize, $daten, $this->serialize_needed, $this->option_receive, $err) === true) {
return $daten;
} else {
//var_dump($err);
}
}
开发者ID:juanber84,项目名称:phpqueue,代码行数:8,代码来源:Consumer.php
示例10: pop
function pop()
{
$ret = msg_receive($this->msg, 0, $this->msgtype, 65525, $data);
if ($ret) {
return $data;
}
return false;
}
开发者ID:zzzzzmh,项目名称:KeywordFilteringService,代码行数:8,代码来源:MsgQ.php
示例11: receive
public function receive($block = false, $serialize = false)
{
$data = [];
$error = 0;
$type = 1;
$block = $block ? MSG_NOERROR : MSG_IPC_NOWAIT;
$res = msg_receive($this->msg, $type, $type, 1024, $data, $serialize, $block, $error);
return $res ? $data : null;
}
开发者ID:heesey,项目名称:epserver,代码行数:9,代码来源:SystemIPC.php
示例12: receiveMessage
/**
* @return string
* @throws \RuntimeException
*/
protected function receiveMessage()
{
$msgtype = $message = null;
// argument #3: specify the maximum number of bytes allowsed in one message queue.
$success = msg_receive($this->id, 1, $msgtype, $this->stat['msg_qbytes'], $message, false);
if (!$success) {
throw new \RuntimeException('failed to receive message.');
}
return $message;
}
开发者ID:ackintosh,项目名称:snidel,代码行数:14,代码来源:AbstractQueue.php
示例13: receive
public function receive($type = 0, &$msgtype = null)
{
if (!msg_receive($this->queue, $type, $msgtype, 65535, $msgdata, true, MSG_IPC_NOWAIT, $error)) {
if ($error == MSG_ENOMSG) {
return null;
}
debug("Error reading from IPC queue 0x%x: %s", $this->key, $error);
return null;
}
return $msgdata;
}
开发者ID:noccy80,项目名称:cherryphp,代码行数:11,代码来源:queue.php
示例14: readAction
public function readAction()
{
$msg_id = msg_get_queue($this->_key, 0600);
while (true) {
if (msg_receive($msg_id, 1, $msg_type, 16384, $msg, true, 0, $msg_error)) {
list($id, $msg) = split('!', $msg);
echo json_encode(array('id' => $id, 'msg' => $msg));
}
}
msg_remove_queue($msg_id);
}
开发者ID:jaredquinn,项目名称:phpTinyFW,代码行数:11,代码来源:Controller.php
示例15: handle
public function handle()
{
$messageQueueKey = ftok(App::path('cache') . "/queue/daemon.queue", "a");
$messageQueue = msg_get_queue($messageQueueKey, 0666);
$count = 0;
while ($count < 5) {
msg_receive($messageQueue, 0, $messageType, 1024, $message, true, MSG_IPC_NOWAIT);
File::appendText(App::path('cache') . "/" . __CLASS__ . ".txt", $message);
sleep(2);
}
}
开发者ID:sanzhumu,项目名称:xaircraft1.1,代码行数:11,代码来源:ScheduleDaemon.php
示例16: get
public function get($queueName, $timeout = null)
{
if (null !== $timeout) {
throw new \LogicException("Semaphore provider doesn't support timeout");
}
if (msg_receive($this->getQueue($queueName), 1, $type, 1024, $workload, true, MSG_IPC_NOWAIT)) {
return $workload;
} else {
return null;
}
}
开发者ID:riverline,项目名称:worker-bundle,代码行数:11,代码来源:Semaphore.php
示例17: sendMessage
public function sendMessage($data)
{
//Generate a random ID for this request
$id = rand();
$message = [$id, $data];
msg_send($this->queue, $this->serverId, $message, true, false);
msg_receive($this->queue, $id, $msgtype, 1000000, $msg, true);
foreach ($msg[0] as $header) {
header($header);
}
return $msg[1];
}
开发者ID:level-2,项目名称:aphplication,代码行数:12,代码来源:Client.php
示例18: read
public function read($desiredTopic = 0)
{
$this->initialize();
switch ($this->method) {
case null:
throw new Exception('You have to setMethod() first');
break;
case self::QM_MSGQUEUE:
$topic = 0;
$msg = null;
if (msg_receive($this->queueRes, $desiredTopic, &$topic, 16384, &$msg, true, MSG_IPC_NOWAIT | MSG_NOERROR)) {
return $msg;
}
return false;
break;
case self::QM_ZEROMQ:
break;
case self::QM_LIBEVENT:
break;
case self::QM_FILESOCKET:
$socket = @socket_create(AF_UNIX, SOCK_STREAM, 0);
if (!$socket) {
return false;
}
if (!@socket_connect($socket, $this->queuePath . 'queue.' . $this->queueId)) {
$err = socket_last_error();
if (ECONNREFUSED == $err) {
throw new Exception('Connection error. Queue-server (service.php) not running?');
}
}
if (false === socket_write($socket, serialize(array('topic' => $topic, 'msg' => $msg)))) {
return false;
}
socket_close($socket);
break;
case self::QM_FILESYS:
$files = glob($this->queuePath . $desiredTopic . DS . 'q.*', GLOB_NOSORT);
if (empty($files)) {
return null;
}
natsort($files);
$file = array_shift($files);
$fileContent = file_get_contents($file);
@unlink($file);
if (false !== $fileContent) {
return unserialize($fileContent);
}
return false;
break;
}
//switch
}
开发者ID:emente,项目名称:kataii---kata-framework-2.x,代码行数:52,代码来源:queue.php
示例19: get
/**
* 从队列获取一个
* @return bool
* @throws Exception
*/
public function get()
{
$queue_status = $this->status();
if ($queue_status['msg_qnum'] > 0) {
if (\msg_receive($this->queue, $this->msg_type, $msgtype_erhalten, $this->maxsize, $data, $this->serialize_needed, $this->option_receive, $err) === true) {
return $data;
} else {
throw new \Exception($err);
}
} else {
return false;
}
}
开发者ID:gzweb,项目名称:Zebra-PHP-Framework,代码行数:18,代码来源:SystemVMessageQueue.class.php
示例20: populateFromQueue
private function populateFromQueue()
{
$type = 1;
$data = NULL;
while (false !== msg_receive($this->queue, 1, $type, 16384, $data, false, MSG_IPC_NOWAIT)) {
$uid = Common::substrUntil($data, ':');
$message = Common::substrFrom($data, ':');
echo "GOT {$uid}:{$message}\n";
if (false !== ($socket = $this->getSocketByResourceB($uid))) {
$frame = WebSocketFrame::create(WebSocketOpcode::TextFrame, $message);
$socket->write($frame->encode());
}
}
}
开发者ID:sinfocol,项目名称:gwf3,代码行数:14,代码来源:websocket.server.php
注:本文中的msg_receive函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论