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; }
public function shutdown() { $this->queue = msg_get_queue(ftok($this->file, 'R'), 0777); for ($i = 0; $i < $this->numThreads * 2; $i++) { msg_send($this->queue, 100 + $i, 'shutdown'); } }
public function initialize() { if ($this->queuePath) { return; } $this->queuePath = KATATMP . 'queue' . DS; if (defined('QUEUE_IDENTIFIER')) { $this->queueId = QUEUE_IDENTIFIER; } else { if (defined('CACHE_IDENTIFIER')) { $this->queueId = (int) hexdec(md5(CACHE_IDENTIFIER)); } else { $this->queueId = ftok(__FILE__); } } switch ($this->method) { case null: throw new Exception('You have to setMethod() first'); break; case self::QM_MSGQUEUE: $this->queueRes = msg_get_queue($this->queueId, 0666); break; case self::QM_ZEROMQ: break; case self::QM_LIBEVENT: break; case self::QM_FILESOCKET: break; case self::QM_FILESYS: break; } //switch }
public function __construct() { $this->ipc_fn = tempnam(sys_get_temp_dir(), 'csp.' . uniqid('chn', true)); $this->key = ftok($this->ipc_fn, 'A'); $this->ipc = msg_get_queue($this->key, 0666); msg_set_queue($this->ipc, $cfg = ['msg_qbytes' => 1 * PHP_INT_LENGTH]); }
/** * Init Tunnel. */ public function __construct() { $this->parentPID = getmypid(); $this->bridge = $this->createBridge(); $this->queue = msg_get_queue(ftok(__FILE__, 'k')); pcntl_signal(POLL_MSG, [$this, 'read']); }
public function setKey($key) { if ($this->key !== $key) { $this->key = $key; $this->queue = msg_get_queue($this->key); } }
public static function getInstance() { if (!self::$_queue) { self::$_queue = msg_get_queue(self::LC_MSG_KEY); } return self::$_queue; }
protected function initQueue() { if (null !== $this->msgHandle) { return; } $this->msgHandle = msg_get_queue($this->getId()); }
public function __construct(Config $config) { $this->ownerPid = $config->get('ownerPid'); $this->ipcKey = new IpcKey($this->ownerPid, str_replace('\\', '_', get_class($this))); $this->id = msg_get_queue($this->ipcKey->generate()); $this->stat = msg_stat_queue($this->id); }
private function getQueue() { if ($this->_queue === null) { $this->_queue = msg_get_queue($this->getKey(), $this->permissions); } return $this->_queue; }
public function __construct($id, $info) { $this->id = $id; $this->info = $info; $this->msgSemKey = sem_get(9876543210); $this->queKey = msg_get_queue(123456788); }
public function __construct($queue_file) { if (!file_exists($queue_file)) { throw new Exception("Could not find mailbox: {$queue_file}"); } $this->queue_id = msg_get_queue(ftok($queue_file, 'r'), 0666); }
/** * init queue * * @param $ipc_filename * @param $msg_type * @throws \Exception */ protected function initQueue($ipc_filename, $msg_type) { $this->key_t = $this->getIpcKey($ipc_filename, $msg_type); $this->queue = \msg_get_queue($this->key_t); if (!$this->queue) { throw new \RuntimeException('msg_get_queue failed'); } }
/** * @param EventDispatcherInterface $dispatcher * @param array $customEvents Custom events to proxy to parent process. */ public function __construct(EventDispatcherInterface $dispatcher, array $customEvents = []) { $this->dispatcher = $dispatcher; $class = new \ReflectionClass('\\Unteist\\Event\\EventStorage'); $this->events = array_unique(array_values($class->getConstants() + $customEvents)); $this->parentPID = getmypid(); $this->queue = msg_get_queue(ftok(__FILE__, 'U')); }
/** * @param int $ownerPid * @param int $maxProcs */ public function __construct($ownerPid, $maxProcs) { $this->keyPrefix = uniqid((string) mt_rand(1, 100), true); $this->ownerPid = $ownerPid; $this->maxProcs = $maxProcs; $this->id = msg_get_queue($this->genId()); $this->initializeQueue(); }
/** * Create a ParallelChildCollector that will collect * issues as normal, but emit them to a message queue * for collection by a * \Phan\Output\Collector\ParallelParentCollector. */ public function __construct() { assert(extension_loaded('sysvsem'), 'PHP must be compiled with --enable-sysvsem in order to use -j(>=2).'); assert(extension_loaded('sysvmsg'), 'PHP must be compiled with --enable-sysvmsg in order to use -j(>=2).'); // Create a message queue for this process group $message_queue_key = posix_getpgid(posix_getpid()); $this->message_queue_resource = msg_get_queue($message_queue_key); }
protected function getQueue($queueName) { if (!isset($this->semaphore[$queueName])) { $id = crc32($queueName); $this->semaphore[$queueName] = msg_get_queue($id); } return $this->semaphore[$queueName]; }
/** * Get queue * * @return resource */ public function getQueue() { if (!($this->queue = msg_get_queue($this->qid, 0666))) { throw new Hush_Message_Exception("Get queue " . $this->name . " failed"); return false; } return $this->queue; }
/** * 初始化一个队列 * @param $ipc_filename * @param $msg_type * @throws Exception */ public function init_queue($ipc_filename, $msg_type) { $this->key_t = $this->get_ipc_key($ipc_filename, $msg_type); $this->queue = \msg_get_queue($this->key_t); if (!$this->queue) { throw new \Exception('msg_get_queue failed'); } }
/** Put a Message Into the Queue */ static function mqSend($name, $type, $mess) { $mq = msg_get_queue(self::_ftok($name)); $block = true; $error = null; if (msg_send($mq, $type, $mess, true, $block, $error)) { return true; } }
/** * @throws \RuntimeException */ protected function init() { $file = sprintf("%s/%s", sys_get_temp_dir(), base64_encode($this->identifier)); @touch($file); $this->queue = msg_get_queue(ftok($file, 'm')); if (!$this->queue) { throw new \RuntimeException("Unable to get message queue"); } }
public function __construct($message, $option = []) { $this->id = crc32($message); $this->perms = $option['perms'] ? $option['perms'] : 0666; if ($option['reset']) { $msg = msg_get_queue($this->id, $this->perms); $msg && msg_remove_queue($msg); } $this->msg = msg_get_queue($this->id, $this->perms); }
private function initQueues() { if (false === ($this->queue_in = msg_get_queue(1000 + $this->server->getID()))) { return false; } if (false === ($this->queue_out = msg_get_queue(2000 + $this->server->getID()))) { return false; } return true; }
/** * Constructor. * * @param int $key A message queue numeric ID * * @throws \RuntimeException */ public function __construct($key) { $this->key = $key; $this->handle = msg_get_queue((int) $key); if (!is_resource($this->handle)) { throw new \RuntimeException(sprintf('Could not get the message queue with key "%s".', $key)); } $stat = $this->getStat(); $this->closed = false; $this->queueMaxSize = $stat['msg_qbytes']; }
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); }
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); } }
public function open() { if ($this->hqueue) { return true; } $qh = msg_get_queue($this->ipckey, 0600); if (!$qh) { throw new \Exception("Unable to open queue (key={$this->ipckey})"); } $this->hqueue = $qh; }
protected function init() { if (!$this->initialized) { $this->logger->info(sprintf("Initialize queue (key: 0x%08x, blocking %s, blockingTimeout: %s)", $this->key, $this->blocking, $this->blockingTimeout)); $this->seg = @msg_get_queue($this->key, $this->perms); if (!$this->seg) { //$this->logger->fatal("msg_get_queue: ({$this->name}) (".serialize($GLOBALS["warnings"]).")"); throw new Scalr_System_Ipc_Exception(sprintf("msg_get_queue failed for key 0x%08x", $this->key)); } $this->initialized = true; } }
/** * getQueue: Returns the semaphore message resource. * * @access public */ public static function getQueue() { # Some unique ID define('QUEUE_KEY', 12345); # Different type of actions define('QUEUE_TYPE_START', 1); define('QUEUE_TYPE_END', 2); # Setup the queue self::$queue = msg_get_queue(QUEUE_KEY); # Return the queue return self::$queue; }
function __construct($config) { if (!empty($config['msgid'])) { $this->msgid = $config['msgid']; } else { $this->msgid = ftok(__FILE__, __CLASS__); } if (!empty($config['msgtype'])) { $this->msgtype = $config['msgtype']; } $this->msg = msg_get_queue($this->msgid); }