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


PHP ftok函数代码示例

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


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

示例1: __construct

 /**
  * Init Tunnel.
  */
 public function __construct()
 {
     $this->parentPID = getmypid();
     $this->bridge = $this->createBridge();
     $this->queue = msg_get_queue(ftok(__FILE__, 'k'));
     pcntl_signal(POLL_MSG, [$this, 'read']);
 }
开发者ID:komex,项目名称:tunnel,代码行数:10,代码来源:Tunnel.php

示例2: alloc

 /**
  * Memory alloc
  */
 protected function alloc()
 {
     if (null !== $this->memory) {
         return;
     }
     $this->memory = shm_attach(ftok(__FILE__, $this->identifier), $this->segmentSize, 0644);
 }
开发者ID:cityware,项目名称:city-shared-memory,代码行数:10,代码来源:Bloc.php

示例3: Server

 function Server($address = '0', $port = 8001, $verboseMode = false)
 {
     $this->console("Server starting...");
     $this->address = $address;
     $this->port = $port;
     $this->verboseMode = $verboseMode;
     // socket creation
     $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
     socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
     if (!is_resource($socket)) {
         $this->console("socket_create() failed: " . socket_strerror(socket_last_error()), true);
     }
     if (!socket_bind($socket, $this->address, $this->port)) {
         $this->console("socket_bind() failed: " . socket_strerror(socket_last_error()), true);
     }
     if (!socket_listen($socket, 20)) {
         $this->console("socket_listen() failed: " . socket_strerror(socket_last_error()), true);
     }
     $this->master = $socket;
     $this->sockets = array($socket);
     $this->console("Server started on {$this->address}:{$this->port}");
     // Creating a Shared Memory Zone in RAM
     $this->console("Trying to allocate memory");
     $shm_key = ftok(__FILE__, 't');
     $shm_size = 1024 * 1024;
     // 1MB
     $this->shm = shm_attach($shm_key, $shm_size);
     // Launching...
     $this->run();
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:30,代码来源:websocketdaemonTask.class.php

示例4: shutdown

 public function shutdown()
 {
     $this->queue = msg_get_queue(ftok($this->file, 'R'), 0777);
     for ($i = 0; $i < $this->numThreads * 2; $i++) {
         msg_send($this->queue, 100 + $i, 'shutdown');
     }
 }
开发者ID:level-2,项目名称:aphplication,代码行数:7,代码来源:Aphplication.php

示例5: settingCheck

 protected function settingCheck(&$setting)
 {
     //有一些配置是DIServer运行必须控制的。
     if ($setting['task_worker_num'] <= 0) {
         throw new BootException("Error: 配置swoole.task_worker_num被设置为0。");
     }
     if ($setting['task_ipc_mode'] != 2) {
         throw new BootException("Error: 配置swoole.task_ipc_mode设置不是2。");
     }
     if ($setting['dispatch_mode'] == 1 || $setting['dispatch_mode'] == 3) {
         throw new BootException("Error: 配置swoole.dispatch_mode=1/3时,底层会屏蔽onConnect/onClose事件,原因是这2种模式下无法保证onConnect/onClose/onReceive的顺序。");
     }
     if (isset($setting['chroot'])) {
         throw new BootException("Error: 配置swoole.chroot会导致autoloader无法在工作\\任务进程正常使用,请确定你能处理(如修改autoloader的路径)然后过来注释这个异常。");
     }
     if (!isset($setting['package_eof'])) {
         $setting['package_eof'] = '';
         //疑似swoole bug,如果不显式指定package_eof则无法正常收包。
     }
     if (!isset($setting['task_tmpdir'])) {
         $setting['task_tmpdir'] = Application::GetServerPath('/Runtimes/TaskTemp');
     }
     if (!isset($setting['log_file'])) {
         $setting['log_file'] = Application::GetServerPath('/Runtimes/Log/' . Application::GetServerName() . '.log');
     }
     if (!isset($setting['message_queue_key'])) {
         $setting['message_queue_key'] = ftok(Application::GetServerPath(), 0);
     }
     $setting['daemonize'] = DI_DAEMONIZE;
 }
开发者ID:szyhf,项目名称:DIServer,代码行数:30,代码来源:SwooleSetting.php

示例6: getKey

 /**
  * Return a number representing the current queue.
  * @return integer
  */
 private function getKey()
 {
     if ($this->_key === null) {
         $this->_key = ftok(__FILE__, $this->id);
     }
     return $this->_key;
 }
开发者ID:highestgoodlikewater,项目名称:yii2-nfy,代码行数:11,代码来源:SysVQueue.php

示例7: Map2GE

function Map2GE($x, $y)
{
    if (0) {
        $SHM_KEY = ftok(__FILE__, chr(4));
        $data = shm_attach($SHM_KEY, 102400, 0666);
        $result = shm_get_var($data, 1);
        $r = $result[$x][$y];
        if (isset($r)) {
            shm_detach($data);
            return $r;
        }
    }
    // ­×¥¿
    $r = t67to97($x, $y);
    $x = $r[0];
    $y = $r[1];
    $proj = "proj -I +proj=tmerc +ellps=aust_SA +lon_0=121 +x_0=250000 +k=0.9999";
    $ret = shell_exec("echo {$x} {$y} | {$proj}");
    if (preg_match("/(\\d+)d(\\d+)'([\\d.]+)\"E\\s+(\\d+)d(\\d+)'([\\d.]+)\"N/", $ret, $matches)) {
        list($junk, $ed, $em, $es, $nd, $nm, $ns) = $matches;
        $r[0] = $ed + $em / 60 + $es / 3600;
        $r[1] = $nd + $nm / 60 + $ns / 3600;
        if (0) {
            $result[$x][$y] = $r;
            shm_put_var($data, 1, $result);
            shm_detach($data);
        }
        return $r;
    }
    return FALSE;
    // exit;
}
开发者ID:KevinStoneCode,项目名称:twmap,代码行数:32,代码来源:kml_lib.php

示例8: alloc

 /**
  * Memory alloc
  */
 protected function alloc()
 {
     if (null !== $this->memory) {
         return;
     }
     $this->memory = shmop_open(ftok(__FILE__, $this->identifier), "c", 0644, $this->segmentSize);
 }
开发者ID:cityware,项目名称:city-shared-memory,代码行数:10,代码来源:Segment.php

示例9: __construct

 public function __construct($queue_file)
 {
     if (!file_exists($queue_file)) {
         throw new Exception("Could not find mailbox: {$queue_file}");
     }
     $this->queue_id = msg_get_queue(ftok($queue_file, 'r'), 0666);
 }
开发者ID:blamh,项目名称:ipc_mailbox,代码行数:7,代码来源:Sender.php

示例10: generate

 /**
  * generate IPC key
  *
  * @return  int
  */
 public function generate()
 {
     if (!file_exists($this->pathname)) {
         touch($this->pathname);
     }
     return ftok($this->pathname, 'S');
 }
开发者ID:ackintosh,项目名称:snidel,代码行数:12,代码来源:IpcKey.php

示例11: init

 public function init()
 {
     $project = chr(getmypid() % 26 + 65);
     $dir = Yii::getPathOfAlias('application.runtime.cache');
     if (!is_dir($dir)) {
         mkdir($dir);
     }
     $this->fileName = $dir . DIRECTORY_SEPARATOR . 'cache_' . $project . ".dump";
     try {
         $shmKey = ftok(__FILE__, $project);
         if ($shmKey < 0) {
             throw new CException('Bad ftok');
         }
         $this->shmId = @shmop_open($shmKey, "c", 0644, $this->maxSize);
         if ($this->shmId == 0) {
             throw new CException('Bad shmop');
         }
         $try = @unserialize(shmop_read($this->shmId, 0, 0));
         $this->offsetWrite = (int) $try;
         if ($this->offsetWrite == 0) {
             $this->saveOffsetWrite(true);
         } else {
             $this->detectStart();
         }
     } catch (Exception $e) {
         Yii::log('Unable to init shared memory', CLogger::LEVEL_ERROR, 'sharedMemory');
     }
 }
开发者ID:niranjan2m,项目名称:Voyanga,代码行数:28,代码来源:SharedMemory.php

示例12: initialize

 public function initialize()
 {
     if ($this->queuePath) {
         return;
     }
     $this->queuePath = KATATMP . 'queue' . DS;
     if (defined('QUEUE_IDENTIFIER')) {
         $this->queueId = QUEUE_IDENTIFIER;
     } else {
         if (defined('CACHE_IDENTIFIER')) {
             $this->queueId = (int) hexdec(md5(CACHE_IDENTIFIER));
         } else {
             $this->queueId = ftok(__FILE__);
         }
     }
     switch ($this->method) {
         case null:
             throw new Exception('You have to setMethod() first');
             break;
         case self::QM_MSGQUEUE:
             $this->queueRes = msg_get_queue($this->queueId, 0666);
             break;
         case self::QM_ZEROMQ:
             break;
         case self::QM_LIBEVENT:
             break;
         case self::QM_FILESOCKET:
             break;
         case self::QM_FILESYS:
             break;
     }
     //switch
 }
开发者ID:emente,项目名称:kataii---kata-framework-2.x,代码行数:33,代码来源:queue.php

示例13: __construct

 private function __construct()
 {
     /* if wndows */
     /*
     function ftok($pathname, $proj_id) {
        $st = @stat($pathname);
        if (!$st) {
           return -1;
        }
     
        $key = sprintf("%u", (($st['ino'] & 0xffff) | (($st['dev'] & 0xff) << 16) | (($proj_id & 0xff) << 24)));
        return $key;
     */
     $shm_key = ftok(__FILE__, 't');
     $this->mShmId = shmop_open($shm_key, 'ac', 0, 0);
     if ($this->mShmId) {
         #it is already created
         //echo '#it is already created';
     } else {
         #you need to create it with shmop_open using "c" only
         //echo '#you need to create it with shmop_open using "c" only';
         $this->mShmId = shmop_open($shm_key, 'c', $this->_SHM_AC_, $this->_SHM_SIZE_);
     }
     $this->mShmId = shmop_open($shm_key, 'w', 0, 0);
     //echo 'ShmId:'.$this->mShmId;
     $this->ShmIsClean = false;
 }
开发者ID:rifkiferdian,项目名称:gtfw_boostab,代码行数:27,代码来源:SharedMemory.class.php

示例14: provideMutexFactories

 /**
  * Provides Mutex factories.
  *
  * @return callable[][] The mutex factories.
  */
 public function provideMutexFactories()
 {
     $cases = ["NoMutex" => [function () {
         return new NoMutex();
     }], "TransactionalMutex" => [function () {
         $pdo = new \PDO("sqlite::memory:");
         $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         return new TransactionalMutex($pdo);
     }], "FlockMutex" => [function () {
         vfsStream::setup("test");
         return new FlockMutex(fopen(vfsStream::url("test/lock"), "w"));
     }], "SemaphoreMutex" => [function () {
         return new SemaphoreMutex(sem_get(ftok(__FILE__, "a")));
     }], "SpinlockMutex" => [function () {
         $mock = $this->getMockForAbstractClass(SpinlockMutex::class, ["test"]);
         $mock->expects($this->any())->method("acquire")->willReturn(true);
         $mock->expects($this->any())->method("release")->willReturn(true);
         return $mock;
     }], "LockMutex" => [function () {
         $mock = $this->getMockForAbstractClass(LockMutex::class);
         $mock->expects($this->any())->method("lock")->willReturn(true);
         $mock->expects($this->any())->method("unlock")->willReturn(true);
         return $mock;
     }]];
     if (getenv("MEMCACHE_HOST")) {
         $cases["MemcacheMutex"] = [function () {
             $memcache = new Memcache();
             $memcache->connect(getenv("MEMCACHE_HOST"));
             return new MemcacheMutex("test", $memcache);
         }];
         $cases["MemcachedMutex"] = [function () {
             $memcache = new Memcached();
             $memcache->addServer(getenv("MEMCACHE_HOST"), 11211);
             return new MemcachedMutex("test", $memcache);
         }];
     }
     if (getenv("REDIS_URIS")) {
         $uris = explode(",", getenv("REDIS_URIS"));
         $cases["PredisMutex"] = [function () use($uris) {
             $clients = array_map(function ($uri) {
                 return new Client($uri);
             }, $uris);
             return new PredisMutex($clients, "test");
         }];
         $cases["PHPRedisMutex"] = [function () use($uris) {
             $apis = array_map(function ($uri) {
                 $redis = new Redis();
                 $uri = parse_url($uri);
                 if (!empty($uri["port"])) {
                     $redis->connect($uri["host"], $uri["port"]);
                 } else {
                     $redis->connect($uri["host"]);
                 }
                 return $redis;
             }, $uris);
             return new PHPRedisMutex($apis, "test");
         }];
     }
     return $cases;
 }
开发者ID:hyperunknown,项目名称:lock,代码行数:65,代码来源:MutexTest.php

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


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