// Exception constants
const EXCEPTION_TASK_IS_INVALID = 0xb00;
- /**
- * A task list instance
- */
- private $listInstance = null;
-
- /**
- * Instance for iterator
- */
- private $iteratorInstance = null;
-
/**
* Visitor instance for all tasks while they are active
*/
parent::__construct(__CLASS__);
// Init the task list
- $this->listInstance = ObjectFactory::createObjectByConfiguredName('task_list_class');
+ $this->setListInstance(ObjectFactory::createObjectByConfiguredName('task_list_class'));
// Get default instance
- $this->iteratorInstance = $this->listInstance->getIterator();
+ $this->setIteratorInstance($this->getListInstance()->getIterator());
// Init visitor instance for faster loop
$this->visitorInstance = ObjectFactory::createObjectByConfiguredName('active_task_visitor_class');
$updateTask = false;
// Is the current task valid?
- if (!$this->iteratorInstance->valid()) {
+ if (!$this->getIteratorInstance()->valid()) {
// Not valid!
throw new InvalidTaskException($this, self::EXCEPTION_TASK_IS_INVALID);
} // END - if
// Get current task
- $currentTask = $this->iteratorInstance->current();
+ $currentTask = $this->getIteratorInstance()->current();
// Is the task not yet started?
if ($currentTask['task_started'] === false) {
*/
private function updateTask (array $taskEntry) {
// Get the key from current iteration
- $key = $this->iteratorInstance->key();
+ $key = $this->getIteratorInstance()->key();
// Get the hash from key
- $hash = $this->listInstance->getHash($key);
+ $hash = $this->getListInstance()->getHash($key);
// Update the entry
- $this->listInstance->updateCurrentEntryByHash($hash, $taskEntry);
+ $this->getListInstance()->updateCurrentEntryByHash($hash, $taskEntry);
}
/**
*/
private function unregisterTask ($taskName) {
// Remove the entry
- $this->listInstance->removeEntry('tasks', $taskName);
+ $this->getListInstance()->removeEntry('tasks', $taskName);
}
/**
);
// Add the entry
- $this->listInstance->addEntry('tasks', $taskEntry);
+ $this->getListInstance()->addEntry('tasks', $taskEntry);
// Debug message
$this->debugOutput('TASK-HANDLER: Task ' . $taskName .
*/
public function hasTasksLeft () {
// Do we have tasks there?
- $tasksLeft = (($this->listInstance instanceof Listable) && ($this->listInstance->count() > 0));
+ $tasksLeft = (($this->getListInstance() instanceof Listable) && ($this->getListInstance()->count() > 0));
// Return result
return $tasksLeft;
*/
public function handleTasks () {
// Should we rewind?
- if (!$this->iteratorInstance->valid()) {
+ if (!$this->getIteratorInstance()->valid()) {
// Rewind to the beginning for next loop
- $this->iteratorInstance->rewind();
+ $this->getIteratorInstance()->rewind();
} // END - if
// Try to execute the task
$this->executeCurrentTask();
// Go to next entry
- $this->iteratorInstance->next();
+ $this->getIteratorInstance()->next();
}
/**
*/
public function doShutdown () {
// Should we rewind?
- if (!$this->iteratorInstance->valid()) {
+ if (!$this->getIteratorInstance()->valid()) {
// Rewind to the beginning for next loop
- $this->iteratorInstance->rewind();
+ $this->getIteratorInstance()->rewind();
} // END - if
// Debug message
- $this->debugOutput('TASK-HANDLER: Shutting down all ' . $this->listInstance->count() . ' tasks...');
+ $this->debugOutput('TASK-HANDLER: Shutting down all ' . $this->getListInstance()->count() . ' tasks...');
// Remember all tasks that has been shutdown for removal
$tasks = array();
// Shutdown all tasks in once go
- while ($this->iteratorInstance->valid()) {
+ while ($this->getIteratorInstance()->valid()) {
// Get current entry
- $current = $this->iteratorInstance->current();
+ $current = $this->getIteratorInstance()->current();
// Output debug message
$this->debugOutput('TASK-HANDLER: Shutting down task ' . $current['id'] . ' (taskInstance=' . $current['task_instance']->__toString() . ') ...');
$tasks[] = $current;
// Advance to next one
- $this->iteratorInstance->next();
+ $this->getIteratorInstance()->next();
} // END - while