• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP time_sleep_until函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: process

 /**
  * Make the script sleep during a given delay
  *
  * @param TryAgain\Handler $handler
  */
 public function process(Handler $handler)
 {
     $delay = $this->getFibonacciNumber();
     if ($delay > 0) {
         time_sleep_until(microtime(true) + $delay);
     }
 }
开发者ID:villfa,项目名称:tryagain,代码行数:12,代码来源:FibonacciInterval.php


示例2: run

 /**
  * 运行守护进程,归档日志文件。
  * 
  * @see ZtChart_Model_Monitor_Abstract::run()
  */
 public function run()
 {
     sleep($this->_console->getDelayTimestamp());
     while (true) {
         $this->_timestamp = $timestamp = time();
         $deadlineTimestamp = $timestamp - self::CYCLE_TIMESTAMP;
         $this->import($this->_console->getLogPaths(), $deadlineTimestamp);
         $storage = new ZtChart_Model_Storage('monitor', 'archive');
         $storage->write($deadlineTimestamp);
         time_sleep_until($timestamp + self::CYCLE_TIMESTAMP);
     }
 }
开发者ID:starflash,项目名称:ZtChart-ZF1-Example,代码行数:17,代码来源:Archive.php


示例3: tickProcessor

 private function tickProcessor()
 {
     while (!$this->server->isShutdown()) {
         $start = microtime(true);
         $this->tick();
         $time = microtime(true);
         if ($time - $start < 0.01) {
             @time_sleep_until($time + 0.01 - ($time - $start));
         }
     }
     $this->tick();
     $this->socket->close();
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:13,代码来源:ServerConnection.php


示例4: tickProcessor

 private function tickProcessor()
 {
     $this->lastMeasure = \microtime(\true);
     while (!$this->shutdown) {
         $start = \microtime(\true);
         $max = 5000;
         while (--$max and $this->receivePacket()) {
         }
         while ($this->receiveStream()) {
         }
         $time = \microtime(\true) - $start;
         if ($time < 0.05) {
             \time_sleep_until(\microtime(\true) + 0.05 - $time);
         }
         $this->tick();
     }
 }
开发者ID:kakichi,项目名称:ClearSky,代码行数:17,代码来源:SessionManager.php


示例5: onCommand

 public function onCommand(ConsoleCommandEvent $event)
 {
     $output = $event->getOutput();
     $input = new ArgvInput();
     try {
         $input->bind($this->getDefinition());
     } catch (\RuntimeException $e) {
     }
     $delay = filter_var($input->getOption('delay'), FILTER_VALIDATE_INT);
     if ($delay > 0) {
         $wakeupAt = time() + mt_rand(1, $delay);
         $output->writeln('<comment>Waiting until ' . date('Y-m-d H:i:s', $wakeupAt) . ' eRepublik time.</comment>');
         time_sleep_until($wakeupAt);
     }
     $this->configPath = $input->getOption('config');
     $this->loadConfig();
 }
开发者ID:erpk,项目名称:erbot,代码行数:17,代码来源:Application.php


示例6: shootThenGo

 /**
  * @param int $shootTime
  * @param int $stopTime
  *
  * @return \Generator
  */
 public function shootThenGo($shootTime, $stopTime)
 {
     $entry = time();
     $timestamp = $shootTime;
     while (true) {
         if ($timestamp > $stopTime) {
             break;
         }
         if ($timestamp > time()) {
             time_sleep_until($timestamp);
         }
         (yield $timestamp);
         if ($timestamp < $entry) {
             $timestamp = $entry;
             continue;
         }
         ++$timestamp;
     }
 }
开发者ID:jiangyu7408,项目名称:notification,代码行数:25,代码来源:Generator.php


示例7: run

 /**
  * Schedules jobs, sleeps until a job has to be scheduled. Returns 
  * when jobs were scheduled.
  *
  * @return int Number of scheduled jobs.
  */
 function run()
 {
     $now = new DateTime('now');
     $sleep = min(array_map(function ($entry) use($now) {
         list($expression, $job) = $entry;
         return $expression->getNextRunDate($now)->getTimestamp();
     }, $this->entries));
     time_sleep_until($sleep);
     $scheduled = 0;
     foreach ($this->entries as $entry) {
         list($expression, $job) = $entry;
         if ($expression->isDue($now)) {
             $this->queue->push($job);
             $scheduled += 1;
         }
     }
     $this->queue->flush();
     return $scheduled;
 }
开发者ID:chh,项目名称:kue,代码行数:25,代码来源:Scheduler.php


示例8: remove_obsolete_hublocs

function remove_obsolete_hublocs()
{
    logger('remove_obsolete_hublocs', LOGGER_DEBUG);
    // Get rid of any hublocs which are ours but aren't valid anymore -
    // e.g. they point to a different and perhaps transient URL that we aren't using.
    // I need to stress that this shouldn't happen. fix_system_urls() fixes hublocs
    // when it discovers the URL has changed. So it's unclear how we could end up
    // with URLs pointing to the old site name. But it happens. This may be an artifact
    // of an old bug or maybe a regression in some newer code. In any event, they
    // mess up communications and we have to take action if we find any.
    // First make sure we have any hublocs (at all) with this URL and sitekey.
    // We don't want to perform this operation while somebody is in the process
    // of renaming their hub or installing certs.
    $r = q("select hubloc_id from hubloc where hubloc_url = '%s' and hubloc_sitekey = '%s'", dbesc(z_root()), dbesc(get_config('system', 'pubkey')));
    if (!$r || !count($r)) {
        return;
    }
    $channels = array();
    // Good. We have at least one *valid* hubloc.
    // Do we have any invalid ones?
    $r = q("select hubloc_id from hubloc where hubloc_sitekey = '%s' and hubloc_url != '%s'", dbesc(get_config('system', 'pubkey')), dbesc(z_root()));
    $p = q("select hubloc_id from hubloc where hubloc_sitekey != '%s' and hubloc_url = '%s'", dbesc(get_config('system', 'pubkey')), dbesc(z_root()));
    if (is_array($r) && is_array($p)) {
        $r = array_merge($r, $p);
    }
    if (!$r) {
        return;
    }
    // We've got invalid hublocs. Get rid of them.
    logger('remove_obsolete_hublocs: removing ' . count($r) . ' hublocs.');
    $interval = get_config('system', 'delivery_interval') !== false ? intval(get_config('system', 'delivery_interval')) : 2;
    foreach ($r as $rr) {
        q("update hubloc set hubloc_deleted = 1 where hubloc_id = %d", intval($rr['hubloc_id']));
        $x = q("select channel_id from channel where channel_hash = '%s' limit 1", dbesc($rr['hubloc_hash']));
        if ($x) {
            Zotlabs\Daemon\Master::Summon(array('Notifier', 'location', $x[0]['channel_id']));
            if ($interval) {
                @time_sleep_until(microtime(true) + (double) $interval);
            }
        }
    }
}
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:42,代码来源:hubloc.php


示例9: runAsDaemon

 /**
  * Keep the app running as a daemon.
  *
  * The app sends a report every X seconds as defined in the daemon.interval config setting.
  *
  * @throws Exceptions\EnsureException if config settings are wrong
  */
 protected function runAsDaemon()
 {
     // interval (in seconds) between sending reports.
     $interval = $this->cfg('daemon.interval');
     Ensure::that($interval > $this->cfg('http.timeout'), 'daemon.interval must be larger than http.timeout in order to run as daemon');
     // start of the reporting
     $start = microtime(true);
     // A practically endless loop
     // 64 bit signed integers gives us 292,471,208,678 years of runtime with 1-second intervals
     // 32 bit signed integers gives us 69 years of runtime with 1-second intervals
     for ($i = 0; true; ++$i) {
         // The ideal starting time of this iteration
         $this_iteration_start = $start + $interval * $i;
         // The ideal starting time of the next iteration
         $next_iteration_start = $this_iteration_start + $interval;
         // Send the report. This may take a few seconds.
         try {
             $this->sendReport();
         } catch (Exception $e) {
             $this->warning('Could not send report to remote server: {message}', ['message' => $e->getMessage()]);
         }
         // Sleep until next iteration should start
         time_sleep_until($next_iteration_start);
     }
 }
开发者ID:moccalotto,项目名称:reporter,代码行数:32,代码来源:App.php


示例10: enforce_min_exec_time

 /**
  * Enforce the minimum execution time. Call this at the end of your long
  * processing to make sure that it doesn't take less time than the
  * minimum execution time. This is used to avoid being blocked by
  * overzealous server protection solutions.
  *
  * @return  void
  */
 public function enforce_min_exec_time()
 {
     // Try to get a sane value for PHP's maximum_execution_time INI parameter
     if (@function_exists('ini_get')) {
         $php_max_exec = @ini_get("maximum_execution_time");
     } else {
         $php_max_exec = 10;
     }
     if ($php_max_exec == "" || $php_max_exec == 0) {
         $php_max_exec = 10;
     }
     // Decrease $php_max_exec time by 500 msec we need (approx.) to tear down
     // the application, as well as another 500msec added for rounding
     // error purposes. Also make sure this is never going to be less than 0.
     $php_max_exec = max($php_max_exec * 1000 - 1000, 0);
     // Get the "minimum execution time per step" Akeeba Backup configuration variable
     $minexectime = $this->min_exec_time;
     if (!is_numeric($minexectime)) {
         $minexectime = 0;
     }
     // Make sure we are not over PHP's time limit!
     if ($minexectime > $php_max_exec) {
         $minexectime = $php_max_exec;
     }
     // Get current running time
     $elapsed_time = $this->getRunningTime() * 1000;
     // Only run a sleep delay if we haven't reached the minexectime execution time
     if ($minexectime > $elapsed_time && $elapsed_time > 0) {
         $sleep_msec = $minexectime - $elapsed_time;
         if (function_exists('usleep')) {
             usleep(1000 * $sleep_msec);
         } elseif (function_exists('time_nanosleep')) {
             $sleep_sec = floor($sleep_msec / 1000);
             $sleep_nsec = 1000000 * ($sleep_msec - $sleep_sec * 1000);
             time_nanosleep($sleep_sec, $sleep_nsec);
         } elseif (function_exists('time_sleep_until')) {
             $until_timestamp = time() + $sleep_msec / 1000;
             time_sleep_until($until_timestamp);
         } elseif (function_exists('sleep')) {
             $sleep_sec = ceil($sleep_msec / 1000);
             sleep($sleep_sec);
         }
     } elseif ($elapsed_time > 0) {
         // No sleep required, even if user configured us to be able to do so.
     }
 }
开发者ID:ranamimran,项目名称:persivia,代码行数:54,代码来源:timer.php


示例11: ratenotif_run

function ratenotif_run($argv, $argc)
{
    cli_startup();
    $a = get_app();
    require_once "session.php";
    require_once "datetime.php";
    require_once 'include/items.php';
    require_once 'include/Contact.php';
    if ($argc < 3) {
        return;
    }
    logger('ratenotif: invoked: ' . print_r($argv, true), LOGGER_DEBUG);
    $cmd = $argv[1];
    $item_id = $argv[2];
    if ($cmd === 'rating') {
        $r = q("select * from xlink where xlink_id = %d and xlink_static = 1 limit 1", intval($item_id));
        if (!$r) {
            logger('rating not found');
            return;
        }
        $encoded_item = array('type' => 'rating', 'encoding' => 'zot', 'target' => $r[0]['xlink_link'], 'rating' => intval($r[0]['xlink_rating']), 'rating_text' => $r[0]['xlink_rating_text'], 'signature' => $r[0]['xlink_sig'], 'edited' => $r[0]['xlink_updated']);
    }
    $channel = channelx_by_hash($r[0]['xlink_xchan']);
    if (!$channel) {
        logger('no channel');
        return;
    }
    $primary = get_directory_primary();
    if (!$primary) {
        return;
    }
    $interval = get_config('system', 'delivery_interval') !== false ? intval(get_config('system', 'delivery_interval')) : 2;
    $deliveries_per_process = intval(get_config('system', 'delivery_batch_count'));
    if ($deliveries_per_process <= 0) {
        $deliveries_per_process = 1;
    }
    $deliver = array();
    $x = z_fetch_url($primary . '/regdir');
    if ($x['success']) {
        $j = json_decode($x['body'], true);
        if ($j && $j['success'] && is_array($j['directories'])) {
            foreach ($j['directories'] as $h) {
                if ($h == z_root()) {
                    continue;
                }
                $hash = random_string();
                $n = zot_build_packet($channel, 'notify', null, null, $hash);
                q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', '%s', %d, '%s', '%s', '%s', '%s' )", dbesc($hash), intval($channel['channel_account_id']), intval($channel['channel_id']), dbesc('zot'), dbesc($h . '/post'), intval(1), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc($n), dbesc(json_encode($encoded_item)));
                $deliver[] = $hash;
                if (count($deliver) >= $deliveries_per_process) {
                    proc_run('php', 'include/deliver.php', $deliver);
                    $deliver = array();
                    if ($interval) {
                        @time_sleep_until(microtime(true) + (double) $interval);
                    }
                }
            }
            // catch any stragglers
            if (count($deliver)) {
                proc_run('php', 'include/deliver.php', $deliver);
            }
        }
    }
    logger('ratenotif: complete.');
    return;
}
开发者ID:msooon,项目名称:hubzilla,代码行数:66,代码来源:ratenotif.php


示例12: run

 public function run()
 {
     $this->add_category('default', array('humanice' => true), PUBLICY);
     $this->cron = Cron::factory();
     $this->cron->attach($this);
     $this->lou = LoU::factory($this->server, $this->email, $this->password, $this->debug);
     if ($this->debug) {
         $this->log("Entered debugmode!");
     }
     $this->lou->attach($this);
     $this->lou->get_self();
     $this->forum = Forum::factory($this->lou);
     $this->igm = Igm::factory($this->lou);
     $this->load_hooks();
     $this->globalchat = defined('GLOBALCHAT') ? GLOBALCHAT : false;
     $this->lou->get_self_alliance();
     $this->lou->setAllianceAllowOnline(true);
     while ($this->lou->isConnected(true)) {
         $slepp_until = time() + POLLTRIP;
         $event = $this->cron->check();
         $chat = $this->lou->check();
         if (time() < $slepp_until) {
             time_sleep_until($slepp_until);
         }
     }
 }
开发者ID:rbraband,项目名称:LouCes,代码行数:26,代码来源:bot.php


示例13: build_sync_packet

/**
 * Send a zot packet to all hubs where this channel is duplicated, refreshing
 * such things as personal settings, channel permissions, address book updates, etc.
 *
 * @param int $uid
 * @param array $packet (optional) default null
 * @param boolean $groups_changed (optional) default false
 */
function build_sync_packet($uid = 0, $packet = null, $groups_changed = false)
{
    $a = get_app();
    logger('build_sync_packet');
    if ($packet) {
        logger('packet: ' . print_r($packet, true), LOGGER_DATA);
    }
    if (!$uid) {
        $uid = local_channel();
    }
    if (!$uid) {
        return;
    }
    $r = q("select * from channel where channel_id = %d limit 1", intval($uid));
    if (!$r) {
        return;
    }
    $channel = $r[0];
    if (intval($channel['channel_removed'])) {
        return;
    }
    $h = q("select * from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0", dbesc($channel['channel_hash']));
    if (!$h) {
        return;
    }
    $synchubs = array();
    foreach ($h as $x) {
        if ($x['hubloc_host'] == $a->get_hostname()) {
            continue;
        }
        $synchubs[] = $x;
    }
    if (!$synchubs) {
        return;
    }
    $r = q("select xchan_guid, xchan_guid_sig from xchan where xchan_hash  = '%s' limit 1", dbesc($channel['channel_hash']));
    if (!$r) {
        return;
    }
    $env_recips = array();
    $env_recips[] = array('guid' => $r[0]['xchan_guid'], 'guid_sig' => $r[0]['xchan_guid_sig']);
    $info = $packet ? $packet : array();
    $info['type'] = 'channel_sync';
    $info['encoding'] = 'red';
    // note: not zot, this packet is very red specific
    if (array_key_exists($uid, $a->config) && array_key_exists('transient', $a->config[$uid])) {
        $settings = $a->config[$uid]['transient'];
        if ($settings) {
            $info['config'] = $settings;
        }
    }
    if ($channel) {
        $info['channel'] = array();
        foreach ($channel as $k => $v) {
            // filter out any joined tables like xchan
            if (strpos($k, 'channel_') !== 0) {
                continue;
            }
            // don't pass these elements, they should not be synchronised
            $disallowed = array('channel_id', 'channel_account_id', 'channel_primary', 'channel_prvkey', 'channel_address', 'channel_deleted', 'channel_removed', 'channel_system');
            if (in_array($k, $disallowed)) {
                continue;
            }
            $info['channel'][$k] = $v;
        }
    }
    if ($groups_changed) {
        $r = q("select hash as collection, visible, deleted, name from groups where uid = %d", intval($uid));
        if ($r) {
            $info['collections'] = $r;
        }
        $r = q("select groups.hash as collection, group_member.xchan as member from groups left join group_member on groups.id = group_member.gid where group_member.uid = %d", intval($uid));
        if ($r) {
            $info['collection_members'] = $r;
        }
    }
    $interval = get_config('system', 'delivery_interval') !== false ? intval(get_config('system', 'delivery_interval')) : 2;
    logger('build_sync_packet: packet: ' . print_r($info, true), LOGGER_DATA);
    foreach ($synchubs as $hub) {
        $hash = random_string();
        $n = zot_build_packet($channel, 'notify', $env_recips, $hub['hubloc_sitekey'], $hash);
        q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', '%s', %d, '%s', '%s', '%s', '%s' )", dbesc($hash), intval($channel['channel_account']), intval($channel['channel_id']), dbesc('zot'), dbesc($hub['hubloc_callback']), intval(1), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc($n), dbesc(json_encode($info)));
        proc_run('php', 'include/deliver.php', $hash);
        if ($interval) {
            @time_sleep_until(microtime(true) + (double) $interval);
        }
    }
}
开发者ID:23n,项目名称:hubzilla,代码行数:96,代码来源:zot.php


示例14: do_delivery

function do_delivery($deliveries)
{
    if (!(is_array($deliveries) && count($deliveries))) {
        return;
    }
    $interval = get_config('system', 'delivery_interval') !== false ? intval(get_config('system', 'delivery_interval')) : 2;
    $deliveries_per_process = intval(get_config('system', 'delivery_batch_count'));
    if ($deliveries_per_process <= 0) {
        $deliveries_per_process = 1;
    }
    $deliver = array();
    foreach ($deliveries as $d) {
        $deliver[] = $d;
        if (count($deliver) >= $deliveries_per_process) {
            proc_run('php', 'include/deliver.php', $deliver);
            $deliver = array();
            if ($interval) {
                @time_sleep_until(microtime(true) + (double) $interval);
            }
        }
    }
    // catch any stragglers
    if ($deliver) {
        proc_run('php', 'include/deliver.php', $deliver);
    }
}
开发者ID:bashrc,项目名称:hubzilla,代码行数:26,代码来源:network.php


示例15: notifier_run


//.........这里部分代码省略.........
                foreach ($r as $rr) {
                    $recipients[] = $rr['id'];
                }
            }
        }
    }
    if ($followup) {
        $recip_str = $parent['contact-id'];
    } else {
        $recip_str = implode(', ', $recipients);
    }
    $r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 AND `pending` = 0 ", dbesc($recip_str));
    require_once 'include/salmon.php';
    $interval = get_config('system', 'delivery_interval') === false ? 2 : intval(get_config('system', 'delivery_interval'));
    // delivery loop
    if (count($r)) {
        foreach ($r as $contact) {
            if (!$mail && !$fsuggest && !$followup && !$contact['self']) {
                if ($contact['network'] === NETWORK_DIASPORA && $public_message) {
                    continue;
                }
                q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )", dbesc($cmd), intval($item_id), intval($contact['id']));
            }
        }
        foreach ($r as $contact) {
            if ($contact['self']) {
                continue;
            }
            // potentially more than one recipient. Start a new process and space them out a bit.
            // we will deliver single recipient types of message and email receipients here.
            if (!$mail && !$fsuggest && !$followup) {
                proc_run('php', 'include/delivery.php', $cmd, $item_id, $contact['id']);
                if ($interval) {
                    @time_sleep_until(microtime(true) + (double) $interval);
                }
                continue;
            }
            $deliver_status = 0;
            logger("main delivery by notifier: followup={$followup} mail={$mail} fsuggest={$fsuggest}");
            switch ($contact['network']) {
                case NETWORK_DFRN:
                    // perform local delivery if we are on the same site
                    $basepath = implode('/', array_slice(explode('/', $contact['url']), 0, 3));
                    if (link_compare($basepath, $a->get_baseurl())) {
                        $nickname = basename($contact['url']);
                        if ($contact['issued-id']) {
                            $sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id']));
                        } else {
                            $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id']));
                        }
                        $x = q("SELECT\t`contact`.*, `contact`.`uid` AS `importer_uid`, \n\t\t\t\t\t\t\t`contact`.`pubkey` AS `cpubkey`, \n\t\t\t\t\t\t\t`contact`.`prvkey` AS `cprvkey`, \n\t\t\t\t\t\t\t`contact`.`thumb` AS `thumb`, \n\t\t\t\t\t\t\t`contact`.`url` as `url`,\n\t\t\t\t\t\t\t`contact`.`name` as `senderName`,\n\t\t\t\t\t\t\t`user`.* \n\t\t\t\t\t\t\tFROM `contact` \n\t\t\t\t\t\t\tLEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` \n\t\t\t\t\t\t\tWHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\t\t\t\tAND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'\n\t\t\t\t\t\t\t{$sql_extra}\n\t\t\t\t\t\t\tAND `user`.`account_expired` = 0 LIMIT 1", dbesc(NETWORK_DFRN), dbesc($nickname));
                        if (count($x)) {
                            require_once 'library/simplepie/simplepie.inc';
                            logger('mod-delivery: local delivery');
                            local_delivery($x[0], $atom);
                            break;
                        }
                    }
                    logger('notifier: dfrndelivery: ' . $contact['name']);
                    $deliver_status = dfrn_deliver($owner, $contact, $atom);
                    logger('notifier: dfrn_delivery returns ' . $deliver_status);
                    if ($deliver_status == -1) {
                        logger('notifier: delivery failed: queuing message');
                        // queue message for redelivery
                        add_to_queue($contact['id'], NETWORK_DFRN, $atom);
                    }
开发者ID:ryivhnn,项目名称:friendica,代码行数:67,代码来源:notifier.php


示例16: gentlyAPICall

 /**
  * API呼び出し制限の10秒当り300回を守る
  *
  * 実のところ、Trello側の制限アルゴリズムが不明なため
  * あまり意味はない。制限に引っかかるとリターンコード
  * 429が返ってくるので、それで処理したほうがベター。
  */
 private function gentlyAPICall()
 {
     if (++$this->apiCall > 300) {
         // もし301回目の呼び出しが11秒を超えている場合はWarningが発生
         // 通常は表示されないが、嫌なら今の時間と比較し回避する
         time_sleep_until($this->benchTime->addSecond(11)->timestamp);
         $this->apiCall = 1;
         $this->benchTime = Carbon::now();
     }
 }
开发者ID:HiroKws,项目名称:zakkuto-laravel-hub-site,代码行数:17,代码来源:TrelloId.php


示例17: blockUntilFileOlderThan

 /**
  * Block until the given file is older than $lockoutS
  * Using this function with a large value of $lockoutS can cause a script
  * timeout.
  *
  * @param string $filename the filename
  * @param integer $lockoutS the minimum number of seconds to wait
  */
 private static function blockUntilFileOlderThan($filename, $lockoutS) {
     if (time() > filemtime($filename) + $lockoutS)
         return;
     @time_sleep_until(filemtime($filename) + $lockoutS);
 }
开发者ID:anubhaBhargava,项目名称:OpenRecommender,代码行数:13,代码来源:GoodreadsParser.php


示例18: do_delivery

function do_delivery($deliveries)
{
    if (!(is_array($deliveries) && count($deliveries))) {
        return;
    }
    $interval = get_config('system', 'delivery_interval') !== false ? intval(get_config('system', 'delivery_interval')) : 2;
    $deliveries_per_process = intval(get_config('system', 'delivery_batch_count'));
    if ($deliveries_per_process <= 0) {
        $deliveries_per_process = 1;
    }
    $deliver = array();
    foreach ($deliveries as $d) {
        if (!$d) {
            continue;
        }
        $deliver[] = $d;
        if (count($deliver) >= $deliveries_per_process) {
            Zotlabs\Daemon\Master::Summon(array('Deliver', $deliver));
            $deliver = array();
            if ($interval) {
                @time_sleep_until(microtime(true) + (double) $interval);
            }
        }
    }
    // catch any stragglers
    if ($deliver) {
        Zotlabs\Daemon\Master::Summon(array('Deliver', $deliver));
    }
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:29,代码来源:network.php


示例19: queue_run

function queue_run(&$argv, &$argc)
{
    global $a, $db;
    if (is_null($a)) {
        $a = new App();
    }
    if (is_null($db)) {
        @(include ".htconfig.php");
        require_once "include/dba.php";
        $db = new dba($db_host, $db_user, $db_pass, $db_data);
        unset($db_host, $db_user, $db_pass, $db_data);
    }
    require_once "include/session.php";
    require_once "include/datetime.php";
    require_once 'include/items.php';
    require_once 'include/bbcode.php';
    require_once 'include/pidfile.php';
    require_once 'include/socgraph.php';
    load_config('config');
    load_config('system');
    $lockpath = get_lockpath();
    if ($lockpath != '') {
        $pidfile = new pidfile($lockpath, 'queue');
        if ($pidfile->is_already_running()) {
            logger("queue: Already running");
            if ($pidfile->running_time() > 9 * 60) {
                $pidfile->kill();
                logger("queue: killed stale process");
                // Calling a new instance
                proc_run('php', "include/queue.php");
            }
            return;
        }
    }
    $a->set_baseurl(get_config('system', 'url'));
    load_hooks();
    if ($argc > 1) {
        $queue_id = intval($argv[1]);
    } else {
        $queue_id = 0;
    }
    $deadguys = array();
    logger('queue: start');
    // Handling the pubsubhubbub requests
    proc_run('php', 'include/pubsubpublish.php');
    $interval = get_config('system', 'delivery_interval') === false ? 2 : intval(get_config('system', 'delivery_interval'));
    // If we are using the worker we don't need a delivery interval
    if (get_config("system", "worker")) {
        $interval = false;
    }
    $r = q("select * from deliverq where 1");
    if ($r) {
        foreach ($r as $rr) {
            logger('queue: deliverq');
            proc_run('php', 'include/delivery.php', $rr['cmd'], $rr['item'], $rr['contact']);
            if ($interval) {
                @time_sleep_until(microtime(true) + (double) $interval);
            }
        }
    }
    $r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`\n\t\tINNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`\n\t\tWHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
    if ($r) {
        foreach ($r as $rr) {
            logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
            logger('Expired queue data :' . $rr['content'], LOGGER_DATA);
        }
        q("DELETE FROM `queue` WHERE `created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
    }
    if ($queue_id) {
        $r = q("SELECT `id` FROM `queue` WHERE `id` = %d LIMIT 1", intval($queue_id));
    } else {
        // For the first 12 hours we'll try to deliver every 15 minutes
        // After that, we'll only attempt delivery once per hour.
        $r = q("SELECT `id` FROM `queue` WHERE (( `created` > UTC_TIMESTAMP() - INTERVAL 12 HOUR && `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ) OR ( `last` < UTC_TIMESTAMP() - INTERVAL 1 HOUR ))");
    }
    if (!$r) {
        return;
    }
    if (!$queue_id) {
        call_hooks('queue_predeliver', $a, $r);
    }
    // delivery loop
    require_once 'include/salmon.php';
    require_once 'include/diaspora.php';
    foreach ($r as $q_item) {
        // queue_predeliver hooks may have changed the queue db details,
        // so check again if this entry still needs processing
        if ($queue_id) {
            $qi = q("select * from queue where `id` = %d limit 1", intval($queue_id));
        } else {
            $qi = q("SELECT * FROM `queue` WHERE `id` = %d AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ", intval($q_item['id']));
        }
        if (!count($qi)) {
            continue;
        }
        $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($qi[0]['cid']));
        if (!count($c)) {
            remove_queue_item($q_item['id']);
            continue;
        }
//.........这里部分代码省略.........
开发者ID:vinzv,项目名称:friendica,代码行数:101,代码来源:queue.php


示例20: attemptFailed

 /**
  * Used to increment the failed attempt counter
  */
 public function attemptFailed($sleep = 0.3)
 {
     if ($this->cd_trigger > 0) {
         $count = $this->session->get($this->key . '.info.fail_count', 0) + 1;
         $total = $this->session->get($this->key . '.info.fail_total', 0) + 1;
         $this->session->set($this->key . '.info.fail_count', $count);
         $this->session->set($this->key . '.info.fail_total', $total);
         $this->session->set($this->key . '.info.last_attempt', time());
     }
     if (is_numeric($sleep)) {
         // optional delay to help slow down brute-force attacks
         time_sleep_until(microtime(true) + abs(floatval($sleep)));
     }
 }
开发者ID:rainner,项目名称:biscuit-php,代码行数:17,代码来源:Login.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP time_str函数代码示例发布时间:2022-05-23
下一篇:
PHP time_since函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap