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


PHP shmop_size函数代码示例

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


在下文中一共展示了shmop_size函数的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: size

 public function size()
 {
     if (null === $this->shmSize) {
         $this->shmSize = shmop_size($this->shmID);
     }
     return $this->shmSize;
 }
开发者ID:panlatent,项目名称:easy-shm,代码行数:7,代码来源:Shm.php

示例3: size

 public function size()
 {
     if ($this->status == self::STATUS_OPENED) {
         return shmop_size($this->shmId);
     }
     return 0;
 }
开发者ID:dan-homorodean,项目名称:falx-concurrency-and-ipc,代码行数:7,代码来源:Handle.php

示例4: get

 /**
  * 读取缓存
  * 
  * @access public
  * @param string $name
  *            缓存变量名
  * @return mixed
  */
 public function get($name = false)
 {
     N('cache_read', 1);
     $id = shmop_open($this->handler, 'c', 0600, 0);
     if ($id !== false) {
         $ret = unserialize(shmop_read($id, 0, shmop_size($id)));
         shmop_close($id);
         if ($name === false) {
             return $ret;
         }
         $name = $this->options['prefix'] . $name;
         if (isset($ret[$name])) {
             $content = $ret[$name];
             if (C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
                 // 启用数据压缩
                 $content = gzuncompress($content);
             }
             return $content;
         } else {
             return null;
         }
     } else {
         return false;
     }
 }
开发者ID:siimanager,项目名称:sii,代码行数:33,代码来源:Shmop.class.php

示例5: delete

 /**
  * Mark a shared memory block for deletion.
  *
  * @return bool
  */
 public function delete()
 {
     /*
      * Bug fix
      * @link https://bugs.php.net/bug.php?id=71921
      */
     shmop_write($this->shmid, str_pad('', shmop_size($this->shmid), ' '), 0);
     return shmop_delete($this->shmid);
 }
开发者ID:anime-db,项目名称:shmop,代码行数:14,代码来源:FixedBlock.php

示例6: MonInit

 function MonInit()
 {
     $this->{$shm_id} = shmop_open(0xff3, "c", 0644, 1024);
     if (!$this->{$shm_id}) {
         debug("No se pudo crear el segmento de memoria compartida\n", "red");
     }
     // Obtencion del tamaño del segmento de memoria compartida
     $shm_size = shmop_size($this->{$shm_id});
     debug("Segmento de memoria: se han reservado " . $shm_size . " bytes.\n", "blue");
 }
开发者ID:BackupTheBerlios,项目名称:ascore,代码行数:10,代码来源:lib_monitor.php

示例7: 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

示例8: get

 function get($key)
 {
     $this->shmop_key = ftok($this->pre . $key);
     //Linux/Unix Only
     $this->shmop_id = shmop_open($this->shmop_key, 'c', 0644, 0);
     if ($this->shmop_id === false) {
         return false;
     }
     $data = shmop_read($this->shmop_id, 0, shmop_size($this->shmop_id));
     shmop_close($this->shmop_id);
     return function_exists('gzuncompress') ? gzuncompress($data) : $data;
 }
开发者ID:hcd2008,项目名称:destoon,代码行数:12,代码来源:cache_shmop.class.php

示例9: __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

示例10: deletemem

 public function deletemem($shmkey)
 {
     $size = shmop_size($shmkey);
     if ($size > 0) {
         $this->updatestats($size, "del");
     }
     if (!shmop_delete($shmkey)) {
         shmop_close($shmkey);
         return false;
     } else {
         shmop_close($shmkey);
         return true;
     }
 }
开发者ID:glial,项目名称:glial,代码行数:14,代码来源:Shmop.php

示例11: stream_read

 function stream_read($count)
 {
     if ($this->body === NULL) {
         $this->id = ftok($this->path, 'M');
         $shm = @shmop_open($this->id, 'a', 0, 0);
         if ($shm) {
             $this->body = shmop_read($shm, 0, shmop_size($shm));
         } else {
             $this->body = file_get_contents($this->path);
         }
     }
     $ret = substr($this->body, $this->position, $count);
     $this->position += strlen($ret);
     return $ret;
 }
开发者ID:tombouctou,项目名称:quicky,代码行数:15,代码来源:memory_cache.class.php

示例12: __destruct

 public function __destruct()
 {
     if ($this->db) {
         $last = STORAGE_PATH . DS . 'memory' . sha1($this->ns . $this->entity) . '.last';
         $size = STORAGE_PATH . DS . 'memory' . sha1($this->ns . $this->entity) . '.dbsize';
         $age = time() - filemtime($last);
         if ($age >= 900) {
             File::delete($last);
             File::create($last);
             $this->write();
         }
         File::delete($size);
         File::put($size, shmop_size($this->db));
         shmop_close($this->db);
     }
 }
开发者ID:noikiy,项目名称:inovi,代码行数:16,代码来源:Fastdb.php

示例13: readAndDelete

 /**
  * read data and delete shared memory
  *
  * @return  mix
  * @throws  RuntimeException
  */
 public function readAndDelete()
 {
     $s = shmop_open($this->genKey(), 'a', 0, 0);
     if ($s === false) {
         throw new RuntimeException('could not open shared memory');
     }
     $data = shmop_read($s, 0, shmop_size($s));
     shmop_close($s);
     try {
         $this->delete();
     } catch (RuntimeException $e) {
         throw $e;
     }
     $unserialized = unserialize($data);
     return $unserialized['data'];
 }
开发者ID:TomoakiNagahara,项目名称:snidel,代码行数:22,代码来源:Data.php

示例14: read

 /**
  * @todo fix mixed return types!
  * @return string|null
  */
 public function read()
 {
     if (!$this->exists()) {
         return null;
     }
     $shmId = @shmop_open($this->shmKey, 'w', 0, 0);
     if (!$shmId) {
         return null;
     }
     $size = @shmop_size($shmId);
     if (!$size) {
         return null;
     }
     $data = @shmop_read($shmId, 0, $size);
     @shmop_close($shmId);
     return (string) $data;
 }
开发者ID:sgc-fireball,项目名称:libphp,代码行数:21,代码来源:SHM.php

示例15: isLocked

 /**
  * Check if process is locked
  *
  * @return bool
  */
 public function isLocked()
 {
     if (0 === $this->getIndexerId()) {
         Mage::throwException('FastIndexer: IndexerId cannot be 0');
     }
     if (null !== $this->_isLocked) {
         return $this->_isLocked;
     }
     $shmId = @shmop_open($this->getIndexerId(), 'a', self::PERM, self::LEN);
     if (false === $shmId) {
         $this->_isLocked = false;
         return $this->_isLocked;
     }
     $size = shmop_size($shmId);
     $startTime = shmop_read($shmId, 0, $size);
     shmop_close($shmId);
     $this->_isLocked = $this->_isLockedByTtl((double) $startTime);
     return $this->_isLocked;
 }
开发者ID:ThomasNegeli,项目名称:Magento-FastIndexer,代码行数:24,代码来源:Shmop.php


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