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


PHP time_nanosleep函数代码示例

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


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

示例1: initScan

 /**
  * Init scan process.
  * Solution for realtime output find on: http://stackoverflow.com/questions/1281140/run-process-with-realtime-output-in-php
  * Maybe ugly, but sometimes at 3AM it's only what is getting out of head ;-)
  */
 public function initScan()
 {
     $view = new Views('templates/head.tpl.php');
     $view->set('class', 'scanner');
     print $view->render();
     set_time_limit(0);
     $handle = popen(PHP . " scanner.php " . $this->project_id, "r");
     if (ob_get_level() == 0) {
         ob_start();
     }
     while (!feof($handle)) {
         $buffer = fgets($handle);
         $buffer = trim(htmlspecialchars($buffer));
         $data = explode(';', $buffer);
         switch ($data[0]) {
             case 'FOUND':
                 print "<div class=\"infobox\"><h3>Found something</h3><p><strong>Time:</strong> " . $data[1] . "<br><strong>Filter name:</strong> " . $data[2] . "<br><strong>Line:</strong> " . $data[3] . "<br><strong>File:</strong> " . $data[4] . "</p><a href=\"/report/" . $data[5] . "\" target=\"_blank\"><span class=\"button warning_button\" style=\"\">Show report</span></a></div>";
                 break;
             case 'NOT_FOUND':
                 print "<div class=\"infobox\"><h3>WOW!</h3><p>Scanner didn't found anything. So your project is sooo secure. You are security mastah, or the filters are too weak ;-) Anyway, I recommend to do a manual code review, to be 100% sure ;-)</p></div>";
                 break;
             case 'SCANNED':
                 print "<div class=\"infobox\"><h3>Hmmmm...</h3><p>Your project has been scanned before. Please go to project to check your reports. <br><a href=\"/show/" . $this->project_id . "\" target=\"_parent\"><span class=\"button\">Go to project page</span></a></p></div>";
                 break;
         }
         ob_flush();
         flush();
         time_nanosleep(0, 10000000);
     }
     pclose($handle);
     ob_end_flush();
 }
开发者ID:beejhuff,项目名称:sec-scanner,代码行数:37,代码来源:Scanner.php

示例2: millisecond

 /**
  * Sleeps for the given amount of milliseconds
  *
  * @param $ms
  */
 public static function millisecond($ms)
 {
     if (($sec = (int) ($ms / 1000)) > 0) {
         $ms = $ms % 1000;
     }
     time_nanosleep($sec, $ms * 1000000);
 }
开发者ID:c2is,项目名称:ApnsSender,代码行数:12,代码来源:Sleep.php

示例3: QueryNominatim

 function QueryNominatim($query, $countryCodes = [], $searchLimit = "10", $boundingBox = [])
 {
     $curlString = self::NOMINATIM_URL_BASE . '/search?format=json';
     $curlString .= '&limit=' . $searchLimit;
     $curlString .= '&email=' . self::NOMINATIM_EMAIL;
     $curlString .= '&addressdetails=1';
     if ($countryCodes) {
         $curlString .= "&countrycodes=" . implode(',', $countryCodes);
     }
     if ($boundingBox) {
         $curlString .= "&viewbox=" . $boundingBox["west"];
         $curlString .= "," . $boundingBox["north"];
         $curlString .= "," . $boundingBox["east"];
         $curlString .= "," . $boundingBox["south"];
         $curlString .= "&bounded=1";
     }
     $curlString .= '&q=' . $query;
     if (printOutput()) {
         echo "<br>Executing query: " . $curlString . "<br>";
     }
     if (self::LIMIT_QUERIES) {
         while ($this->lastQueryTime + 1.0 > microtime(true)) {
             time_nanosleep(0, 10000);
         }
     }
     $this->lastQueryTime = microtime(true);
     return json_decode(Connectivity::runCurl($curlString), true);
 }
开发者ID:spotzi,项目名称:Geotagger,代码行数:28,代码来源:Geotagger.php

示例4: send

 public function send($labels)
 {
     foreach ($labels as $label) {
         time_nanosleep(0, 100000000);
         $this->connector->send($label);
     }
 }
开发者ID:robmachado,项目名称:webetiq,代码行数:7,代码来源:Job.php

示例5: run

 public function run($args)
 {
     while (1) {
         $this->_logger->log(__METHOD__ . ' ' . 'NEW CIRCULE');
         $this->dataExchange();
         time_nanosleep(0, 20000000);
     }
 }
开发者ID:anton-itscript,项目名称:WM-Web,代码行数:8,代码来源:TcpServerCommand.php

示例6: setUp

 /**
  * setUp test suite
  *
  * @return void
  */
 public function setUp()
 {
     $options = new ConnectionOptions();
     if (!self::$isGnatsd) {
         time_nanosleep(2, 0);
         $options->port = 4222;
     }
     $this->c = new Nats\Connection($options);
     $this->c->connect();
 }
开发者ID:pprasse,项目名称:phpnats,代码行数:15,代码来源:ConnectionTest.php

示例7: setUp

 /**
  * setUp test suite
  *
  * @return void
  */
 public function setUp()
 {
     $options = new ConnectionOptions();
     if (!self::$isGnatsd) {
         time_nanosleep(1, 700000000);
         $options->setPort(4222);
     }
     $this->c = new Nats\Connection($options);
     $this->c->connect();
 }
开发者ID:aquilax,项目名称:phpnats,代码行数:15,代码来源:ConnectionTest.php

示例8: isProcessRunning

 private static function isProcessRunning($pid)
 {
     try {
         $output = shell_exec("ps -p  {$pid}");
         if (count(preg_split("/\n/", $output)) > 2) {
             time_nanosleep(0, 500000);
             return true;
         }
     } catch (Exception $e) {
     }
     return false;
 }
开发者ID:arteam,项目名称:orders-system,代码行数:12,代码来源:AppTest.php

示例9: reserveRDaemon

function reserveRDaemon()
{
    global $projectHome;
    for ($counter = 1; $counter <= 30; $counter++) {
        // wait up to 3 seconds
        $reservedRInstance = reserveRInstance();
        if ($reservedRInstance != NULL) {
            return $reservedRInstance;
        }
        time_nanosleep(0, 100000000);
    }
    return null;
}
开发者ID:EU-OSHA,项目名称:esener,代码行数:13,代码来源:reserve.php

示例10: testGetTime

 public function testGetTime()
 {
     $timer = new Timer();
     time_nanosleep(0, 200000000);
     $result1 = $timer->getTime();
     time_nanosleep(0, 300000000);
     $result2 = $timer->getTime(true);
     time_nanosleep(0, 100000000);
     $result3 = $timer->getTime();
     $this->assertTrue(0.2 <= $result1 && $result1 <= 0.205, $result1);
     $this->assertTrue(0.5 <= $result2 && $result2 <= 0.505, $result2);
     $this->assertTrue(0.1 <= $result3 && $result3 <= 0.105, $result3);
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:13,代码来源:TimerTest.php

示例11: __construct

 public function __construct()
 {
     $this->filepath__ = Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'nosqlvars' . DIRECTORY_SEPARATOR . $this->filename__;
     if (!file_exists($this->filepath__)) {
         $array = $this->initFieldsValues();
         file_put_contents($this->filepath__, json_encode($array, true));
     }
     $this->fileData__ = json_decode(file_get_contents($this->filepath__), true);
     while ($this->fileData__ == false) {
         time_nanosleep(0, 200000000);
         $this->fileData__ = json_decode(file_get_contents($this->filepath__), true);
     }
     $this->setValuesAsProperties();
 }
开发者ID:anton-itscript,项目名称:WM-Web,代码行数:14,代码来源:PFileModel.php

示例12: await

 /**
  * Causes the current thread to wait until the latch has counted down to zero, unless the thread is interrupted.
  *
  * @param int $timeout
  * @param TimeUnit|null $unit the timeunit of the given timeout
  * @return bool true if the count reached zero and false if the waiting time elapsed before the count reached zero
  */
 public function await($timeout = 0, TimeUnit $unit = null)
 {
     if (null !== $unit) {
         $timeout = $unit->toMicros($timeout);
     }
     $timeoutAt = microtime(true) + $timeout / 1000000;
     while (0 != $this->count) {
         if ($timeout > 0 && microtime(true) > $timeoutAt) {
             return false;
         }
         time_nanosleep(0, 1);
     }
     return true;
 }
开发者ID:prolic,项目名称:concurrent-php-utils,代码行数:21,代码来源:CountDownLatch.php

示例13: waitForLock

 private function waitForLock($failSafe = false)
 {
     $wait_counter = 0;
     while (file_exists($this->email_file_loc . ".lock")) {
         $wait_counter++;
         if ($wait_counter > 100) {
             if (!$failSafe) {
                 throw new Exception("Email time-out waiting for lock", 1);
             } else {
                 return false;
             }
         }
         time_nanosleep(0, 100000000);
         //sleep for a 10th of a second.
     }
     return true;
 }
开发者ID:AngryShrimp,项目名称:CME495_Design_IMS,代码行数:17,代码来源:IMSEmail.php

示例14: uploadOrders

 protected function uploadOrders($orders)
 {
     if (sizeof($orders)) {
         $orders = array_chunk($orders, $this->config['retailcrm_order_chunk_size']);
         foreach ($orders as $chunk) {
             try {
                 $result = $this->crmClient->ordersUpload($chunk);
                 if (!$result->isSuccessful()) {
                     $this->writeLog('ordersUpload: ' . $result['errorMsg'] . (isset($result['errors']) ? ': ' . json_encode($result['errors']) : ''));
                 }
                 time_nanosleep(0, 200000000);
             } catch (\RetailCrm\Exception\CurlException $e) {
                 $this->writeLog('ordersUpload: ' . $e, 'error');
             }
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:retailcrm,项目名称:tiu-client,代码行数:20,代码来源:ApiHelper.php

示例15: cache_get

function cache_get($url, $cache_file, $verbose = true, $update = false, $cache_life = 43200)
{
    $message = '';
    $content = '';
    clearstatcache();
    if ($url == '') {
        $message .= '[empty url]';
    } else {
        if (file_exists($cache_file) && time() - filemtime($cache_file) <= $cache_life) {
            $message .= '[use cache]';
            $content = @file_get_contents($cache_file);
        } else {
            $message .= '[update cache : ';
            if ($update && file_exists($cache_file) && curl_get_file_size($url) <= filesize($cache_file)) {
                $message .= 'cache file is already bigger';
                $content = @file_get_contents($cache_file);
            } else {
                if (($content = curl_download($url)) !== false) {
                    // @file_get_contents($url)
                    rmkdir(dirname($cache_file));
                    if (($size = @file_put_contents($cache_file, $content)) === false) {
                        $message .= 'not updatable (' . $cache_file . ')';
                    } else {
                        $message .= 'updated (' . human_filesize($size) . ')';
                    }
                    if (strpos($url, 'http://www.magic-ville.com') !== false) {
                        time_nanosleep(0, 500000000);
                    }
                    // Avoid anti-leech mechanism on MV (30 queries every 15 sec)
                } else {
                    $message .= 'not downloadable (' . $url . ')';
                }
            }
            $message .= ']';
        }
    }
    if ($verbose) {
        echo $message;
    }
    return $content;
}
开发者ID:OlivierLamiraux,项目名称:mtgas,代码行数:41,代码来源:lib.php


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