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


PHP msg_receive函数代码示例

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


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


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