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


PHP sem_release函数代码示例

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


在下文中一共展示了sem_release函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: release

 /**
  * Release a semaphore
  * After releasing the semaphore, acquire() may be called to re-acquire it. 
  *
  * @return  bool success
  * @throws  io.IOException
  * @see     xp://io.sys.Semaphore#acquire
  */
 public function release()
 {
     if (FALSE === sem_release($this->_hdl)) {
         throw new IOException('Could not release semaphore ' . $this->key);
     }
     return TRUE;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:15,代码来源:Semaphore.class.php

示例2: unlock

 /**
  * @return bool
  */
 public function unlock()
 {
     $released = sem_release($this->lock);
     sem_remove($this->lock);
     $this->lock = null;
     return $released;
 }
开发者ID:CrakLabs,项目名称:ipc-component,代码行数:10,代码来源:SmLock.php

示例3: registerChildPID

 /**
  * Registers the PID of a child-process
  *
  * @param int The PID
  */
 public function registerChildPID($pid)
 {
     $sem_key = sem_get($this->crawler_uniqid);
     sem_acquire($sem_key);
     file_put_contents($this->working_directory . "pids", $pid . "\n", FILE_APPEND);
     sem_release($sem_key);
 }
开发者ID:haythameyd,项目名称:socialfp,代码行数:12,代码来源:PHPCrawlerProcessHandler.class.php

示例4: getNextValueByShareMemory

/**
 * 通过本机共享内存件来生成一个auto_increment序列
 *
 * 序列类似MySQL的auto_increment
 *
 * @access private
 * @param  void
 * @return mixed
 */
function getNextValueByShareMemory()
{
    $addr = '127.0.0.1';
    if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $addr = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } elseif (!empty($_SERVER['SERVER_ADDR'])) {
        $addr = $_SERVER['SERVER_ADDR'];
    }
    $skey = 'global_serial_generator_seed_' . $addr;
    $ikey = crc32($skey);
    $sem = $shm = null;
    $retry_times = 1;
    do {
        $sem = sem_get($ikey, 1, 0777);
        $shm = shm_attach($ikey, 128, 0777);
        if (is_resource($sem) && is_resource($shm)) {
            break;
        }
        $cmd = "ipcrm -M 0x00000000; ipcrm -S 0x00000000; ipcrm -M {$ikey} ; ipcrm -S {$ikey}";
        $last_line = exec($cmd, $output, $retval);
    } while ($retry_times-- > 0);
    if (!sem_acquire($sem)) {
        return false;
    }
    $next_value = false;
    if (shm_has_var($shm, $ikey)) {
        shm_put_var($shm, $ikey, $next_value = shm_get_var($shm, $ikey) + 1);
    } else {
        shm_put_var($shm, $ikey, $next_value = 1);
    }
    $shm && shm_detach($shm);
    $sem && sem_release($sem);
    return $next_value;
}
开发者ID:fixbugs,项目名称:pubfunc-php,代码行数:43,代码来源:pub.serial.php

示例5: session_value

function session_value($name, $index)
{
    global $shm_key, $shm_var, $sem_id;
    switch ($index) {
        case 'config':
            $shm_size = 859;
            break;
        case 'ipdata':
            $shm_size = 30050;
            break;
        default:
            $shm_size = 0;
    }
    sem_acquire($sem_id['shlock']);
    $shm_id = shmop_open($shm_key[$index], 'c', 0644, $shm_size);
    if ($name == 'update') {
        $shm_data = serialize($shm_var[$index]);
        shmop_write($shm_id, str_pad($shm_data, $shm_size, "", STR_PAD_RIGHT), 0);
    } else {
        $shm_data = shmop_read($shm_id, 0, $shm_size);
        $shm_var[$index] = @unserialize($shm_data);
    }
    shmop_close($shm_id);
    sem_release($sem_id['shlock']);
}
开发者ID:phateio,项目名称:php-radio-kernel,代码行数:25,代码来源:shmop.inc.php

示例6: generate

 /**
  * @return IdValue
  */
 public function generate()
 {
     $timestamp = $this->generateTimestamp();
     // Acquire semaphore
     $semaphore = sem_get($this->semaphoreId);
     sem_acquire($semaphore);
     // Attach shared memory
     $memory = shm_attach(self::SHM_KEY);
     $sequence = 0;
     if (!is_null($this->lastTimestamp) && $timestamp->equals($this->lastTimestamp)) {
         // Get
         $sequence = shm_get_var($memory, self::SHM_SEQUENCE) + 1 & $this->config->getSequenceMask();
         // Increment sequence
         shm_put_var($memory, self::SHM_SEQUENCE, $sequence);
         if ($sequence === 0) {
             usleep(1000);
             $timestamp = $this->generateTimestamp();
         }
     } else {
         // Reset sequence if timestamp is different from last one.
         $sequence = 0;
         shm_put_var($memory, self::SHM_SEQUENCE, $sequence);
     }
     // Detach shared memory
     shm_detach($memory);
     // Release semaphore
     sem_release($semaphore);
     // Update lastTimestamp
     $this->lastTimestamp = $timestamp;
     return new IdValue($timestamp, $this->regionId, $this->serverId, $sequence, $this->calculate($timestamp, $this->regionId, $this->serverId, $sequence));
 }
开发者ID:ada-u,项目名称:chocoflake,代码行数:34,代码来源:IdWorkerOnSharedMemory.php

示例7: release

 /**
  * Release a semaphore
  * After releasing the semaphore, acquire() may be called to re-acquire it. 
  *
  * @return  bool success
  * @throws  io.IOException
  * @see     xp://io.sys.Semaphore#acquire
  */
 public function release()
 {
     if (false === sem_release($this->_hdl)) {
         throw new \io\IOException('Could not release semaphore ' . $this->key);
     }
     return true;
 }
开发者ID:xp-framework,项目名称:core,代码行数:15,代码来源:Semaphore.class.php

示例8: put

 public static function put($killID, $raw)
 {
     $file = static::getFile($killID, true);
     $sem = sem_get(5632);
     // kmdb is 5632 on a phone
     if (!sem_acquire($sem)) {
         throw new Exception('Unable to obtain kmdb semaphore');
     }
     // Thread safe from here until sem_release
     if (!file_exists($file)) {
         $kills = array();
     } else {
         $contents = file_get_contents($file);
         $deflated = gzdecode($contents);
         $kills = unserialize($deflated);
         $contents = null;
     }
     if (!isset($kills["{$killID}"])) {
         $kills["{$killID}"] = $raw;
         $contents = serialize($kills);
         $compressed = gzencode($contents);
         file_put_contents($file, $compressed, LOCK_EX);
     }
     sem_release($sem);
 }
开发者ID:Nord001,项目名称:zKillboard,代码行数:25,代码来源:Killmail.php

示例9: unlock

 /**
  * Unlock process
  *
  * @return Mage_Index_Model_Process
  */
 public function unlock()
 {
     $this->_getSemIdentifier();
     shm_remove_var($this->_shmId, $this->getIndexerCodeCrc());
     @sem_release($this->_getSemIdentifier());
     $this->_isLocked = false;
 }
开发者ID:ThomasNegeli,项目名称:Magento-FastIndexer,代码行数:12,代码来源:Semaphore.php

示例10: unlock

 public function unlock()
 {
     if (PHP_OS !== 'Linux') {
         return;
     }
     sem_release($this->getSemaphoreId());
     $this->locked = false;
 }
开发者ID:jost125,项目名称:koala-parallel,代码行数:8,代码来源:BinarySemaphore.php

示例11: del

 /**
  * Delete shared memory var
  */
 public function del()
 {
     sem_acquire($this->__mutex);
     //block until released
     @shm_remove_var($this->__shm, $this->__key);
     sem_release($this->__mutex);
     //release mutex
 }
开发者ID:nejtr0n,项目名称:shmestage,代码行数:11,代码来源:SharedMemory.php

示例12: get

 /**
  * @param $key
  * @param int $size
  * @return mixed
  */
 public function get($key, $size = 10000)
 {
     $result = $this->attach($key, $size);
     sem_acquire($result['mutex']);
     $value = @shm_get_var($result['shm'], $key);
     sem_release($result['mutex']);
     return $value;
 }
开发者ID:bes89,项目名称:sharedmemory,代码行数:13,代码来源:SharedMemory.php

示例13: release

 /**
  * release lock
  * @throws \RuntimeException
  */
 public function release()
 {
     if ($this->locked) {
         if (!sem_release($this->lock_id)) {
             throw new \RuntimeException('Cannot release semaphore: ' . $this->lock_id);
         }
         $this->locked = false;
     }
 }
开发者ID:jzxyouok,项目名称:simple-fork-php,代码行数:13,代码来源:Semaphore.php

示例14: __destruct

 function __destruct()
 {
     if (null !== $this->shmHandle) {
         shm_detach($this->shmHandle);
     }
     if (null !== $this->semHandle) {
         sem_release($this->semHandle);
     }
 }
开发者ID:emente,项目名称:kataii---kata-framework-2.x,代码行数:9,代码来源:event.php

示例15: unlock

 public static function unlock($sem_id)
 {
     if (substr(PHP_OS, 0, 3) == 'WIN') {
         // if Windows OS detected just return true;
         return true;
     }
     sem_release($sem_id);
     // release semaphore lock
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:9,代码来源:__mySyncFile.class.php


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