當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LBFactory::singleton方法代碼示例

本文整理匯總了PHP中LBFactory::singleton方法的典型用法代碼示例。如果您正苦於以下問題:PHP LBFactory::singleton方法的具體用法?PHP LBFactory::singleton怎麽用?PHP LBFactory::singleton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在LBFactory的用法示例。


在下文中一共展示了LBFactory::singleton方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: wfGetLBFactory

/**
 * Get the load balancer factory object
 *
 * @return LBFactory
 */
function wfGetLBFactory()
{
    return LBFactory::singleton();
}
開發者ID:D66Ha,項目名稱:mediawiki,代碼行數:9,代碼來源:GlobalFunctions.php

示例2: wfGetDB

}
$dbw = wfGetDB(DB_SLAVE);
// define socket which listens for a break signal
$socket = socket_create_listen("9876");
// port is freely chosen
socket_set_nonblock($socket);
// max number of threads to be considered to calculate sleeping time
define('MAX_THREADS_CONSIDERED', 10);
global $wgLoadBalancer;
print "-------------------------------------------------\n";
print " Running jobs... ({$rate} jobs/second)    \t\t \n";
print "-------------------------------------------------\n";
for (;;) {
    // determine the most lagged slave
    // if $lag == -1, there's no slave.
    list($host, $lag) = LBFactory::singleton()->getMainLB()->getMaxLag();
    if ($lag == -1) {
        // make sleeping time adaptive to database load.
        $runningThreads = smwfGetNumOfRunningThreads($dbw);
        $runningThreads = $runningThreads <= MAX_THREADS_CONSIDERED ? $runningThreads : MAX_THREADS_CONSIDERED;
        // wait depending on user-defined $rate and server load
        sleep(1 / $rate + $runningThreads);
    } else {
        // wait for most lagged slave to be *below* 1/$rate + 3 seconds lag time.
        wfWaitForSlaves(1 / $rate + 3);
    }
    // get next job
    $job = Job::pop();
    // is there a break signal?
    $accept_sock = @socket_accept($socket);
    if ($accept_sock !== false) {
開發者ID:seedbank,項目名稱:old-repo,代碼行數:31,代碼來源:SMW_runJobsInBackground.php


注:本文中的LBFactory::singleton方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。