本文整理汇总了PHP中msg_remove_queue函数的典型用法代码示例。如果您正苦于以下问题:PHP msg_remove_queue函数的具体用法?PHP msg_remove_queue怎么用?PHP msg_remove_queue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了msg_remove_queue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __destruct
public function __destruct()
{
if ($this->ipcKey->isOwner(getmypid())) {
$this->ipcKey->delete();
return msg_remove_queue($this->id);
}
}
示例2: __destruct
public function __destruct()
{
if ($this->keyPrefix . getmypid() === $this->getKey()) {
unlink('/tmp/' . sha1($this->getKey()));
return msg_remove_queue($this->id);
}
}
示例3: clear
/**
* {@inheritdoc}
*/
public function clear()
{
if (!msg_remove_queue($this->getQueue())) {
throw new QueueException($this, 'Failed to destroy the queue.');
}
$this->queue = null;
}
示例4: destroyAndWaitForChildren
/**
* Destroy every resource and wait for zombies.
*/
protected function destroyAndWaitForChildren()
{
msg_remove_queue($this->getQueueManager());
sem_remove($this->getLockManager());
for ($i = 0; $i <= $this->childNumber; $i++) {
pcntl_wait($status);
}
}
示例5: close
public function close()
{
$this->closed = true;
do {
$this->out();
--$this->msg_count;
} while ($this->msg_count >= 0);
msg_remove_queue($this->ipc);
file_exists($this->ipc_fn) && @unlink($this->ipc_fn);
}
示例6: __construct
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);
}
示例7: 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);
}
示例8: start
public function start()
{
set_time_limit(0);
if (file_exists($this->file)) {
unlink($this->file);
}
file_put_contents($this->file, '');
$this->queue = msg_get_queue(ftok($this->file, 'R'), 0777);
msg_set_queue($this->queue, []);
msg_remove_queue($this->queue);
$this->queue = msg_get_queue(ftok($this->file, 'R'), 0777);
$this->listen();
}
示例9: initQueue
public static function initQueue($queue_file)
{
if (!file_exists($queue_file)) {
touch($queue_file);
}
$msg_id = msg_get_queue(ftok($queue_file, 'r'), 0666);
// Remove any messages in queue
$queue = msg_stat_queue($msg_id);
if ($queue['msg_qnum'] > 0) {
msg_remove_queue($msg_id);
$msg_id = msg_get_queue(ftok($queue_file, 'r'), 0666);
}
return $msg_id;
}
示例10: drop
public function drop()
{
try {
$q = msg_get_queue($this->id, ONPHP_IPC_PERMS);
} catch (BaseException $e) {
// removed in race
return true;
}
if (!msg_remove_queue($q)) {
// trying to flush manually
$type = $msg = null;
while (msg_receive($q, 0, $type, 2, $msg, false, MSG_IPC_NOWAIT)) {
// do nothing
}
}
return true;
}
示例11: __destruct
/**
* The class destructor.
*/
public function __destruct()
{
parent::__destruct();
if ($this->iAmParent()) {
$desiredType = 1;
$option_receive = MSG_IPC_NOWAIT;
$stats = msg_stat_queue($this->queueResourceResponse);
$queueMessageSize = $stats['msg_qbytes'];
// the Report
$messageReport = '';
// receive the report
$stats = msg_stat_queue($this->queueResourceResponse);
while ($stats['msg_qnum']) {
//for($i=0;count($all_servers);$i++){
$status = msg_receive($this->queueResourceResponse, $desiredType, $type, $queueMessageSize, $mixed, true, $option_receive);
if ($status == true) {
$messageReport .= $mixed['message'];
if ($mixed['return'] < 0) {
// check if server counldn't do the backups because shutdown doesn't work
if ($mixed['error'] && $mixed['error']['error']['error'] == '_ERR_VM_BACKUP_STILL_RUNNING_') {
$etva_server = $mixed['server'];
$this->log("[WARN] Receive error that VM '" . $etva_server->getName() . "' couldn't make backup beacuse is still running, so i will try start again...");
$etva_node = $etva_server->getEtvaNode();
if ($etva_node) {
$res_start = $etva_node->soapSend(EtvaServer_VA::SERVER_START, array('uuid' => $etva_server->getUuid(), 'name' => $etva_server->getName()));
$this->log("[WARN] Start '" . $etva_server->getName() . "' VM and receive the following message: " . print_r($res_start, true));
}
}
}
} else {
$err_m = "[ERROR] Receive error when wait for response... " . print_r($err, true);
$messageReport .= $err_m . "\r\n";
$this->log($err_m);
}
$stats = msg_stat_queue($this->queueResourceResponse);
}
msg_remove_queue($this->queueResourceResponse);
//$this->log($messageReport);
$this->sendReport($messageReport);
}
}
示例12: array
<?php
$tests = array(null, 'foo');
foreach ($tests as $q) {
if ($q === null) {
do {
$id = ftok(__FILE__, chr(mt_rand(0, 255)));
} while (msg_queue_exists($id));
$q = msg_get_queue($id) or die("Failed to create queue");
msg_remove_queue($q) or die("Failed to close queue");
}
echo "Using '{$q}' as queue resource:\n";
$errno = 0;
var_dump(msg_set_queue($q, array('msg_qbytes' => 1)));
var_dump(msg_stat_queue($q));
var_dump(msg_receive($q, 0, $null, 1, $msg, true, 0, $errno));
var_dump($errno != 0);
// again, but triggering an E_WARNING
var_dump(msg_receive($q, 0, $null, 0, $msg));
var_dump(msg_send($q, 1, 'foo', true, true, $errno));
var_dump($errno != 0);
}
echo "Done\n";
示例13: delete
/**
* Delete message from queue
*
* @param int $pid
* @param callable $callback function handler
* @return boolean
*/
public function delete($pid = null, callable $callback = null)
{
$this->queuePid = is_null($pid) === false ? $pid : $this->queuePid;
if (msg_queue_exists($this->queuePid) === true) {
msg_remove_queue(msg_get_queue($this->queuePid));
return true;
}
return false;
}
示例14: __destruct
public function __destruct()
{
// Shut down and remove the queue
$success = msg_remove_queue($this->message_queue_resource);
assert($success, "Failed to remove queue with ID {$this->message_queue_resource}");
}
示例15: free
/**
* Removes the semaphore if it still exists.
*
* @throws SemaphoreException If the operation failed.
*/
public function free()
{
if (is_resource($this->queue) && msg_queue_exists($this->key)) {
if (!msg_remove_queue($this->queue)) {
throw new SemaphoreException('Failed to free the semaphore.');
}
$this->queue = null;
}
}