本文整理汇总了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) {