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


PHP hphp_get_thread_id函数代码示例

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


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

示例1: ctx_log_msg

function ctx_log_msg($func, $text, $type)
{
    global $_context_log;
    if ($_context_log) {
        fprintf($_context_log, "%f %s %d %d %s %s %s\n", microtime(true), php_uname('n'), posix_getpid(), function_exists("hphp_get_thread_id") ? hphp_get_thread_id() : posix_getpid(), $type, $func, $text);
    }
}
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:7,代码来源:context.php

示例2: uuid

 /**
  * Generate a random UUID
  *
  * @see http://www.ietf.org/rfc/rfc4122.txt
  * @return RFC 4122 UUID
  */
 public static function uuid()
 {
     $node = env('SERVER_ADDR');
     if (strpos($node, ':') !== false) {
         if (substr_count($node, '::')) {
             $node = str_replace('::', str_repeat(':0000', 8 - substr_count($node, ':')) . ':', $node);
         }
         $node = explode(':', $node);
         $ipv6 = '';
         foreach ($node as $id) {
             $ipv6 .= str_pad(base_convert($id, 16, 2), 16, 0, STR_PAD_LEFT);
         }
         $node = base_convert($ipv6, 2, 10);
         if (strlen($node) < 38) {
             $node = null;
         } else {
             $node = crc32($node);
         }
     } elseif (empty($node)) {
         $host = env('HOSTNAME');
         if (empty($host)) {
             $host = env('HOST');
         }
         if (!empty($host)) {
             $ip = gethostbyname($host);
             if ($ip === $host) {
                 $node = crc32($host);
             } else {
                 $node = ip2long($ip);
             }
         }
     } elseif ($node !== '127.0.0.1') {
         $node = ip2long($node);
     } else {
         $node = null;
     }
     if (empty($node)) {
         $node = crc32(Configure::read('Security.salt'));
     }
     if (function_exists('hphp_get_thread_id')) {
         $pid = hphp_get_thread_id();
     } else {
         if (function_exists('zend_thread_id')) {
             $pid = zend_thread_id();
         } else {
             $pid = getmypid();
         }
     }
     if (!$pid || $pid > 65535) {
         $pid = mt_rand(0, 0xfff) | 0x4000;
     }
     list($timeMid, $timeLow) = explode(' ', microtime());
     $uuid = sprintf("%08x-%04x-%04x-%02x%02x-%04x%08x", (int) $timeLow, (int) substr($timeMid, 2) & 0xffff, mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3f) | 0x80, mt_rand(0, 0xff), $pid, $node);
     return $uuid;
 }
开发者ID:ndreynolds,项目名称:arcs,代码行数:61,代码来源:String.php

示例3: __construct

 public function __construct()
 {
     $state = self::$state;
     if (function_exists('posix_times')) {
         $state .= serialize(posix_times());
     }
     if (!defined('HHVM_VERSION') && function_exists('zend_thread_id')) {
         $state .= zend_thread_id();
     }
     if (function_exists('hphp_get_thread_id')) {
         $state .= hphp_get_thread_id();
     }
     $state .= getmypid() . memory_get_usage();
     $state .= serialize($_ENV);
     $state .= serialize($_SERVER);
     $state .= count(debug_backtrace(false));
     self::$state = hash('sha512', $state, true);
     if (is_null(self::$counter)) {
         list(, self::$counter) = unpack("i", substr(self::$state, 0, 4));
         $seed = $this->generate(strlen(dechex(PHP_INT_MAX)));
         list(, self::$counter) = unpack("i", $seed);
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:23,代码来源:MicroTime.php


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