summaryrefslogtreecommitdiff
path: root/lib/iomaster.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/iomaster.php')
-rw-r--r--lib/iomaster.php25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/iomaster.php b/lib/iomaster.php
index ce77b53b2..979f73e75 100644
--- a/lib/iomaster.php
+++ b/lib/iomaster.php
@@ -32,6 +32,7 @@ class IoMaster
public $id;
protected $multiSite = false;
+ protected $includeGlobalSingletons = true;
protected $managers = array();
protected $singletons = array();
@@ -47,8 +48,9 @@ class IoMaster
$this->monitor = new QueueMonitor();
}
- public function init($multiSite=null)
+ public function init($multiSite=null, $includeGlobalSingletons = true)
{
+ $this->includeGlobalSingletons = $includeGlobalSingletons;
if ($multiSite !== null) {
$this->multiSite = $multiSite;
}
@@ -107,7 +109,7 @@ class IoMaster
*/
protected function instantiate($class)
{
- if (isset($this->singletons[$class])) {
+ if (is_string($class) && isset($this->singletons[$class])) {
// Already instantiated a multi-site-capable handler.
// Just let it know it should listen to this site too!
$this->singletons[$class]->addSite(common_config('site', 'server'));
@@ -116,25 +118,34 @@ class IoMaster
$manager = $this->getManager($class);
+ $caps = $manager->multiSite();
if ($this->multiSite) {
- $caps = $manager->multiSite();
if ($caps == IoManager::SINGLE_ONLY) {
throw new Exception("$class can't run with --all; aborting.");
}
- if ($caps == IoManager::INSTANCE_PER_PROCESS) {
+ if ($caps == IoManager::INSTANCE_PER_PROCESS ||
+ ( $this->includeGlobalSingletons && $caps == IoManager::GLOBAL_SINGLE_ONLY )) {
// Save this guy for later!
// We'll only need the one to cover multiple sites.
- $this->singletons[$class] = $manager;
+ if (is_string($class)){
+ $this->singletons[$class] = $manager;
+ }
$manager->addSite(common_config('site', 'server'));
}
}
- $this->managers[] = $manager;
+ if( $this->includeGlobalSingletons || $caps != IoManager::GLOBAL_SINGLE_ONLY ) {
+ $this->managers[] = $manager;
+ }
}
protected function getManager($class)
{
- return call_user_func(array($class, 'get'));
+ if(is_object($class)){
+ return $class;
+ }else{
+ return call_user_func(array($class, 'get'));
+ }
}
/**