public function main() { @(include_once 'phing/contrib/DocBlox/Parallel/Manager.php'); @(include_once 'phing/contrib/DocBlox/Parallel/Worker.php'); @(include_once 'phing/contrib/DocBlox/Parallel/WorkerPipe.php'); if (!class_exists('DocBlox_Parallel_Worker')) { throw new BuildException('ParallelTask depends on DocBlox being installed and on include_path.', $this->getLocation()); } $mgr = new DocBlox_Parallel_Manager(); $mgr->setProcessLimit($this->threadCount); foreach ($this->nestedTasks as $task) { $worker = new DocBlox_Parallel_Worker(array($task, 'perform'), array($task)); $mgr->addWorker($worker); } $mgr->execute(); }
/** * This method does the work. * @return void */ public function main() { if ($this->list === null && count($this->filesets) == 0 && count($this->filelists) == 0) { throw new BuildException("Need either list, nested fileset or nested filelist to iterate through"); } if ($this->param === null) { throw new BuildException("You must supply a property name to set on each iteration in param"); } if ($this->calleeTarget === null) { throw new BuildException("You must supply a target to perform"); } @(include_once 'phing/contrib/DocBlox/Parallel/Manager.php'); @(include_once 'phing/contrib/DocBlox/Parallel/Worker.php'); @(include_once 'phing/contrib/DocBlox/Parallel/WorkerPipe.php'); if (!class_exists('DocBlox_Parallel_Worker')) { throw new BuildException('ForeachParallelTask depends on DocBlox being installed and on include_path.', $this->getLocation()); } $parallelManager = new DocBlox_Parallel_Manager(); $parallelManager->setProcessLimit($this->threadCount); $mapper = null; if ($this->mapperElement !== null) { $mapper = $this->mapperElement->getImplementation(); } if (trim($this->list)) { $arr = explode($this->delimiter, $this->list); $total_entries = 0; foreach ($arr as $value) { $value = trim($value); $premapped = ''; if ($mapper !== null) { $premapped = $value; $value = $mapper->main($value); if ($value === null) { continue; } $value = array_shift($value); } $this->log("Setting param '{$this->param}' to value '{$value}'" . ($premapped ? " (mapped from '{$premapped}')" : ''), Project::MSG_VERBOSE); $callee = $this->getCallee(); $callee->setTarget($this->calleeTarget); $callee->setInheritAll(true); $callee->setInheritRefs(true); $prop = $callee->createProperty(); $prop->setOverride(true); $prop->setName($this->param); $prop->setValue($value); $worker = new DocBlox_Parallel_Worker(array($callee, 'main'), array($callee)); $parallelManager->addWorker($worker); $total_entries++; } } // filelists foreach ($this->filelists as $fl) { $srcFiles = $fl->getFiles($this->project); $this->process($parallelManager, $this->getCallee(), $fl->getDir($this->project), $srcFiles, array()); } // filesets foreach ($this->filesets as $fs) { $ds = $fs->getDirectoryScanner($this->project); $srcFiles = $ds->getIncludedFiles(); $srcDirs = $ds->getIncludedDirectories(); $this->process($parallelManager, $this->getCallee(), $fs->getDir($this->project), $srcFiles, $srcDirs); } $parallelManager->execute(); if ($this->list === null) { $this->log("Processed {$this->total_dirs} directories and {$this->total_files} files", Project::MSG_VERBOSE); } else { $this->log("Processed {$total_entries} entr" . ($total_entries > 1 ? 'ies' : 'y') . " in list", Project::MSG_VERBOSE); } }