本文整理匯總了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();
}
示例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) {