當前位置: 首頁>>代碼示例>>PHP>>正文


PHP shmop_delete函數代碼示例

本文整理匯總了PHP中shmop_delete函數的典型用法代碼示例。如果您正苦於以下問題:PHP shmop_delete函數的具體用法?PHP shmop_delete怎麽用?PHP shmop_delete使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了shmop_delete函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: send

 /**
  * Writes a message to the shared memory.
  *
  * @param mixed   $message The message to send
  * @param integer $signal  The signal to send afterward
  * @param integer $pause   The number of microseconds to pause after signalling
  */
 public function send($message, $signal = null, $pause = 500)
 {
     $messageArray = array();
     if (($shmId = @shmop_open($this->pid, 'a', 0, 0)) > 0) {
         // Read any existing messages in shared memory
         $readMessage = shmop_read($shmId, 0, shmop_size($shmId));
         $messageArray[] = unserialize($readMessage);
         shmop_delete($shmId);
         shmop_close($shmId);
     }
     // Add the current message to the end of the array, and serialize it
     $messageArray[] = $message;
     $serializedMessage = serialize($messageArray);
     // Write new serialized message to shared memory
     $shmId = shmop_open($this->pid, 'c', 0644, strlen($serializedMessage));
     if (!$shmId) {
         throw new ProcessControlException(sprintf('Not able to create shared memory segment for PID: %s', $this->pid));
     } else {
         if (shmop_write($shmId, $serializedMessage, 0) !== strlen($serializedMessage)) {
             throw new ProcessControlException(sprintf('Not able to write message to shared memory segment for segment ID: %s', $shmId));
         }
     }
     if (false === $signal) {
         return;
     }
     $this->signal($signal ?: $this->signal);
     usleep($pause);
 }
開發者ID:edwardstock,項目名稱:spork,代碼行數:35,代碼來源:SharedMemory.php

示例2: MonClose

 function MonClose()
 {
     if (!shmop_delete($this->{$shm_id})) {
         debug("No se pudo borrar el segmento de memoria compartida.", "red");
     }
     shmop_close($this->{$shm_id});
 }
開發者ID:BackupTheBerlios,項目名稱:ascore,代碼行數:7,代碼來源:lib_monitor.php

示例3: resize

 /**
  * Resize memory block
  * @param int $size
  * @return bool
  */
 protected function resize($size)
 {
     if ($size > $this->max_size) {
         return false;
     }
     //should be called AFTER reading memory (to not loose changing of variables)
     if (empty($this->mem)) {
         return false;
     }
     ignore_user_abort(true);
     set_time_limit(180);
     if (is_array($this->mem)) {
         $this->mem[self::map_info][self::map_info_resized] = $this->mem[self::map_info][self::map_info_resized] + 1;
         $this->mem[self::map_info][self::map_info_resizetime] = time();
     }
     shmop_delete($this->shm);
     shmop_close($this->shm);
     $t = serialize($this->mem);
     $memsize = strlen($t);
     if ($memsize > $size) {
         $size = $memsize + 1000;
     }
     $this->shm = shmop_open($this->shmkey, "n", 0777, $size);
     if (!$this->shm) {
         return false;
     }
     //mmm... oops.
     unset($this->mem);
     $w = shmop_write($this->shm, str_pad($t, shmop_size($this->shm), ' ', STR_PAD_RIGHT), 0);
     if (!$w) {
         return false;
     }
     return true;
 }
開發者ID:rhodesiaxlo,項目名稱:ngx_lua_php_queue,代碼行數:39,代碼來源:ShmMem.php

示例4: read

 /**
  * @param $key
  * @param int $mode
  * @param int $size
  * @return mixed|null
  * @throws OpenSharedMemoryException
  * @throws ReadSharedMemoryException
  * @throws SupportSharedMemoryException
  */
 public static function read($key, $mode = 0644, $size = 100)
 {
     if (!self::checkSHMOPSupport()) {
         return null;
     }
     @($shm_id = shmop_open($key, "a", $mode, $size));
     //read only
     if (!$shm_id) {
         throw new OpenSharedMemoryException("The shared memory block could not be opened");
     }
     @($cached_string = shmop_read($shm_id, 0, $size));
     if (!$cached_string) {
         shmop_delete($shm_id);
         shmop_close($shm_id);
         throw new ReadSharedMemoryException("The shared memory block could not be read");
     }
     $data = json_decode($cached_string, true);
     if (isset($data['expiration']) && time() > $data['expiration'] || !isset($data['expiration'])) {
         shmop_delete($shm_id);
         shmop_close($shm_id);
         return null;
     }
     shmop_close($shm_id);
     return unserialize($data['value']);
 }
開發者ID:splitio,項目名稱:php-client,代碼行數:34,代碼來源:SharedMemory.php

示例5: create

 public function create($key, $buckets = 12281, $size = 10000000)
 {
     if ($key == 0) {
         $this->errmsg = "key is 0";
         return false;
     }
     $this->shmId = @shmop_open($key, 'a', 0, 0);
     if ($this->shmId != false) {
         if (!shmop_delete($this->shmId)) {
             $this->errmsg = 'delete exist shm 0x' . dechex($key) . ' error';
             return false;
         }
     }
     $this->shmId = shmop_open($key, 'c', 0777, $size);
     if ($this->shmId == false) {
         $this->errmsg = 'create shm 0x' . dechex($key) . ' error';
         return false;
     }
     $head['bsize'] = $size;
     $head['size'] = 0;
     $head['buckets'] = $buckets;
     $head['start'] = 24;
     $head['data'] = $buckets * 8 + 24;
     $head['free'] = $buckets * 8 + 24;
     return $this->setHead($head);
 }
開發者ID:luokizz,項目名稱:spp,代碼行數:26,代碼來源:CShmHashMap.php

示例6: rm

 function rm($key)
 {
     $this->shmop_key = ftok($this->pre . $key);
     $this->shmop_id = shmop_open($this->shmop_key, 'c', 0644, 0);
     $result = shmop_delete($this->shmop_id);
     shmop_close($this->shmop_id);
     return $result;
 }
開發者ID:hcd2008,項目名稱:destoon,代碼行數:8,代碼來源:cache_shmop.class.php

示例7: getExceptions

 /**
  * Get all the exceptions added to the shared memory.
  *
  * @return \Throwable[]
  */
 public function getExceptions() : array
 {
     $memory = shmop_open($this->key, "a", 0, 0);
     $exceptions = $this->unserialize($memory);
     shmop_delete($memory);
     shmop_close($memory);
     return $exceptions;
 }
開發者ID:duncan3dc,項目名稱:fork-helper,代碼行數:13,代碼來源:SharedMemory.php

示例8: __unlock

function __unlock()
{
    if (isset($_SERVER['sync'])) {
        shmop_delete($_SERVER['sync']);
        shmop_close($_SERVER['sync']);
        unset($_SERVER['sync']);
    }
}
開發者ID:melogamepay,項目名稱:xp-framework,代碼行數:8,代碼來源:synchronized.sapi.php

示例9: delete

 /**
  * @return boolean
  */
 public function delete()
 {
     if (!$this->exists()) {
         return true;
     }
     $shmId = shmop_open($this->shmKey, 'w', 0, 0);
     $result = (bool) shmop_delete($shmId);
     shmop_close($shmId);
     return $result;
 }
開發者ID:sgc-fireball,項目名稱:libphp,代碼行數:13,代碼來源:SHM.php

示例10: delete

 public function delete($id, $size)
 {
     $shm = $this->open($id, $size);
     if (shmop_delete($shm)) {
         $keyfile = $this->getKeyFile($id);
         if (file_exists($keyfile)) {
             unlink($keyfile);
         }
     }
     return true;
 }
開發者ID:zmwebdev,項目名稱:PHPcookbook-code-3ed,代碼行數:11,代碼來源:pcshm.php

示例11: getCallbackParams

 public function getCallbackParams()
 {
     $shmId = @shmop_open($this->pid, 'a', 0644, 0);
     if (empty($shmId)) {
         return false;
     }
     $datas = unserialize(shmop_read($shmId, 0, shmop_size($shmId)));
     shmop_delete($shmId);
     shmop_close($shmId);
     return $datas;
 }
開發者ID:Lith,項目名稱:nofussframework,代碼行數:11,代碼來源:Task.php

示例12: delete

 /**
  * delete shared memory
  *
  * @return  void
  * @throws  RuntimeException
  */
 public function delete()
 {
     $s = @shmop_open($this->genKey(), 'a', 0, 0);
     if ($s === false) {
         return;
     }
     if (!shmop_delete($s)) {
         throw new RuntimeException('could not delete shared memory');
     }
     shmop_close($s);
     unlink('/tmp/' . sha1($this->pid));
 }
開發者ID:TomoakiNagahara,項目名稱:snidel,代碼行數:18,代碼來源:Data.php

示例13: __destruct

 public function __destruct()
 {
     if ($this->changed) {
         $serialized = serialize($this->data);
         if (strlen($serialized) > shmop_size($this->res)) {
             shmop_delete($this->res);
             $this->res = shmop_open($id, 'c', 0644, ceil(strlen($serialized) * 1.25));
         }
         shmop_write($this->res, $serialized, 0);
     }
     shmop_close($this->res);
 }
開發者ID:wapmorgan,項目名稱:kvstorage,代碼行數:12,代碼來源:Shmop.php

示例14: tearDown

 protected function tearDown()
 {
     if ($shmid = @shmop_open(self::SHMOP_ID, 'w', 0644, 0)) {
         /*
          * Fill memory block for fix bug
          * @link https://bugs.php.net/bug.php?id=71921
          */
         shmop_write($shmid, str_pad('', strlen(self::WORD), ' '), 0);
         shmop_delete($shmid);
         shmop_close($shmid);
     }
 }
開發者ID:anime-db,項目名稱:shmop,代碼行數:12,代碼來源:FixedBlockTest.php

示例15: stream_write

 function stream_write($data)
 {
     $p = $this->path;
     $fp = fopen($p, 'w');
     fwrite($fp, $data);
     fclose($fp);
     $this->id = ftok($this->path, 'M');
     if ($t = @shmop_open($this->id, 'a', 0, 0)) {
         shmop_delete($t);
     }
     $t = shmop_open($this->id, 'c', 0755, strlen($data));
     shmop_write($t, $data, 0);
 }
開發者ID:tombouctou,項目名稱:quicky,代碼行數:13,代碼來源:memory_cache.class.php


注:本文中的shmop_delete函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。