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