application/hub/exceptions/lists/class_InvalidListHashException.php -text
application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php -text
application/hub/exceptions/lists/class_NoListGroupException.php -text
+application/hub/exceptions/tasks/.htaccess -text
+application/hub/exceptions/tasks/class_InvalidTaskException.php -text
application/hub/init.php -text
application/hub/interfaces/.htaccess -text
application/hub/interfaces/connectors/.htaccess -text
application/hub/interfaces/states/client/class_ClientStateable.php -text
application/hub/interfaces/states/hub/.htaccess -text
application/hub/interfaces/states/hub/class_HubStateable.php -text
+application/hub/interfaces/tasks/.htaccess -text
+application/hub/interfaces/tasks/class_Taskable.php -text
application/hub/interfaces/visitor/.htaccess -text
application/hub/interfaces/visitor/class_Visitable.php -text
application/hub/interfaces/visitor/class_Visitor.php -text
application/hub/interfaces/visitor/pool/class_PoolVisitor.php -text
application/hub/interfaces/visitor/pool/listener/.htaccess -text
application/hub/interfaces/visitor/pool/listener/class_ListenerPoolVisitor.php -text
+application/hub/interfaces/visitor/query/.htaccess -text
+application/hub/interfaces/visitor/query/class_QueryVisitor.php -text
+application/hub/interfaces/visitor/tasks/.htaccess -text
+application/hub/interfaces/visitor/tasks/class_TaskVisitor.php -text
application/hub/loader.php -text
application/hub/main/.htaccess -text
application/hub/main/class_ -text
application/hub/main/iterator/pool/shutdown/.htaccess -text
application/hub/main/iterator/pool/shutdown/class_Shutdown -text
application/hub/main/iterator/pool/shutdown/class_ShutdownPoolIterator.php -text
+application/hub/main/iterator/pool/tasks/.htaccess -text
+application/hub/main/iterator/pool/tasks/class_TaskPoolIterator.php -text
application/hub/main/listener/.htaccess -text
application/hub/main/listener/class_ -text
application/hub/main/listener/class_BaseListener.php -text
application/hub/main/visitor/pool/shutdown/.htaccess -text
application/hub/main/visitor/pool/shutdown/class_Shutdown -text
application/hub/main/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php -text
-application/hub/main/visitor/shutdown/.htaccess -text
-application/hub/main/visitor/shutdown/class_Shutdown -text
-application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php -text
+application/hub/main/visitor/tasks/.htaccess -text
+application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php -text
application/hub/starter.php -text
/clear-cache.sh -text
db/.htaccess -text
// CFG: POOL-ENTRIES-LIST-CLASS
$cfg->setConfigEntry('pool_entries_list_class', 'PoolEntriesList');
-// CFG: SHUTDOWN-LISTENER-POOL-VISITOR-CLASS
-$cfg->setConfigEntry('shutdown_listener_pool_visitor_class', 'ShutdownListenerPoolVisitor');
-
// CFG: SHUTDOWN-POOL-ITERATOR-CLASS
$cfg->setConfigEntry('shutdown_pool_iterator_class', 'ShutdownPoolIterator');
-// CFG: HANDLER-LISTENER-POOL-VISITOR-CLASS
-$cfg->setConfigEntry('handler_listener_pool_visitor_class', 'HandlerListenerPoolVisitor');
-
// CFG: HANDLER-POOL-ITERATOR-CLASS
$cfg->setConfigEntry('handler_pool_iterator_class', 'HandlerPoolIterator');
// CFG: NETWORK-PACKAGE-HANDLER-CLASS
$cfg->setConfigEntry('tcp_network_package_handler_class', 'TcpNetworkPackageHandler');
+// CFG: SHUTDOWN-LISTENER-POOL-VISITOR-CLASS
+$cfg->setConfigEntry('shutdown_listener_pool_visitor_class', 'ShutdownListenerPoolVisitor');
+
+// CFG: HANDLER-LISTENER-POOL-VISITOR-CLASS
+$cfg->setConfigEntry('handler_listener_pool_visitor_class', 'HandlerListenerPoolVisitor');
+
+// CFG: ACTIVE-TASK-VISITOR-CLASS
+$cfg->setConfigEntry('active_task_visitor_class', 'ActiveTaskVisitor');
+
// CFG: LIST-GROUP-CLASS
$cfg->setConfigEntry('list_group_class', 'ListGroupList');
$cfg->setConfigEntry('task_handler_class', 'TaskHandler');
// CFG: TASK-NETWORK-PACKAGE-READER-STARTUP-DELAY
-$cfg->setConfigEntry('task_network_package_reader_startup_delay', 5000);
+$cfg->setConfigEntry('task_network_package_reader_startup_delay', 2000);
// CFG: TASK-NETWORK-PACKAGE-READER-INTERVAL-DELAY
$cfg->setConfigEntry('task_network_package_reader_interval_delay', 10);
// CFG: TASK-QUERY-HANDLER-STARTUP-DELAY
-$cfg->setConfigEntry('task_query_handler_startup_delay', 3000);
+$cfg->setConfigEntry('task_query_handler_startup_delay', 1000);
// CFG: TASK-QUERY-HANDLER-INTERVAL-DELAY
$cfg->setConfigEntry('task_query_handler_interval_delay', 10);
$cfg->setConfigEntry('task_idle_loop_startup_delay', 0);
// CFG: TASK-IDLE-LOOP-INTERVAL-DELAY
-$cfg->setConfigEntry('task_idle_loop_interval_delay', 10);
+$cfg->setConfigEntry('task_idle_loop_interval_delay', 0);
// CFG: IDLE-TASK-CLASS
$cfg->setConfigEntry('idle_task_class', 'IdleLoopTask');
// CFG: TASK-LIST-CLASS
$cfg->setConfigEntry('task_list_class', 'TaskList');
+// CFG: TASK-POOL-ITERATOR-CLASS
+$cfg->setConfigEntry('task_pool_iterator_class', 'TaskPoolIterator');
+
// CFG: DEFAULT-ITERATOR-CLASS
$cfg->setConfigEntry('default_iterator_class', 'DefaultIterator');
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * This exception is thrown when a task is invalid
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class InvalidTaskException extends FrameworkException {
+ /**
+ * The super constructor for all exceptions
+ *
+ * @param $messageArray Error message array
+ * @param $code Error code
+ * @return void
+ */
+ public function __construct (array $messageArray, $code) {
+ // Construct the message
+ $message = sprintf("[%s] Current task is invalid which should not happen.",
+ $messageArray[0]->__toString()
+ );
+
+ // Call parent exception constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
* @throws NoListGroupException If the given group is not found
*/
function addEntry ($groupName, $entry);
+
+ /**
+ * Updates the given entry by hash with given array
+ *
+ * @param $hash Hash for this entry
+ * @param $entryArray Array with entry we should update
+ * @return void
+ * @throws InvalidListHashException If the solved hash index is invalid
+ */
+ function updateCurrentEntryByHash ($hash, array $entryArray);
}
//
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for tasks
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Taskable extends FrameworkInterface {
+ /**
+ * Executes the task
+ *
+ * @return void
+ */
+ function execute ();
+}
+
+//
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for the visitor implementation for queries
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface QueryVisitor extends Visitor {
+ /**
+ * Query visitor method for active queries
+ *
+ * @param $queryInstance A Queryable instance
+ * @return void
+ */
+ function visitQuery (Queryable $queryInstance);
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for the visitor implementation for tasks
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface TaskVisitor extends Visitor {
+ /**
+ * Visits the given task instance
+ *
+ * @param $taskInstance A Taskable instance
+ * @return void
+ */
+ function visitTask (Taskable $taskInstance);
+}
+
+// [EOF]
+?>
// Handle the listeners
// @TODO We may have to catch some exceptions here
//$nodeInstance->getListenerPoolInstance()->handleListenerPool();
-
- // Handle the qeues
- //$nodeInstance->getQueryInstance()->handleQueues();
} // END - while
// Debug message
* @return void
*/
public function accept (Visitor $visitorInstance) {
- $this->partialStub('visitor='.$visitorInstance->__toString());
+ // Visit the query connector
+ $visitorInstance->visitQuery($this);
}
}
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
+ // Exception constants
+ const EXCEPTION_TASK_IS_INVALID = 0xb00;
+
/**
* A task list instance
*/
*/
private $iteratorInstance = null;
+ /**
+ * Visitor instance for all tasks while they are active
+ */
+ private $visitorInstance = null;
+
/**
* Protected constructor
*
// Get default instance
$this->iteratorInstance = $this->listInstance->getIterator();
+
+ // Init visitor instance for faster loop
+ $this->visitorInstance = ObjectFactory::createObjectByConfiguredName('active_task_visitor_class');
}
/**
}
/**
- * Registers a task with a task handler. This method throws a
- * TaskAlreadyRegisteredException if the task has already been registered
+ * Tries to execute the given task. If as task should not be started (yet)
+ * or the interval time (see task_interval_delay) is not yet reached the
+ * task is quietly skipped.
+ *
+ * @return void
+ * @throws InvalidTaskException If the current task is invalid
+ */
+ private function executeCurrentTask () {
+ // Update no task by default
+ $updateTask = false;
+
+ // Is the current task valid?
+ if (!$this->iteratorInstance->valid()) {
+ // Not valid!
+ throw new InvalidTaskException($this, self::EXCEPTION_TASK_IS_INVALID);
+ } // END - if
+
+ // Get current task
+ $currentTask = $this->iteratorInstance->current();
+
+ // Is the task not yet started?
+ if ($currentTask['task_started'] === false) {
+ // Determine difference between current time and registration
+ $diff = ($this->getMilliTime() - $currentTask['task_registered']) * 1000;
+
+ // Should we start now?
+ if ($diff < $currentTask['task_startup_delay']) {
+ // Skip this silently
+ return false;
+ } // END - if
+
+ // Launch the task and mark it as updated
+ $currentTask['task_started'] = true;
+ $updateTask = true;
+ } // END - if
+
+ // Get time difference from interval delay
+ $diff = ($this->getMilliTime() - $currentTask['task_last_activity']) * 1000;
+
+ // Is the interval delay reached?
+ if ($diff < $currentTask['task_interval_delay']) {
+ // Should we update the task from startup?
+ if ($updateTask === true) {
+ // Update the task before leaving
+ $this->updateTask($currentTask);
+ } // END - if
+
+ // Skip this silently
+ return false;
+ } // END - if
+
+ // Set last activity
+ $currentTask['task_last_activity'] = $this->getMilliTime();
+
+ // Update the task
+ $this->updateTask($currentTask);
+
+ // And visit/run it
+ // @TODO Messurement can be added around this call
+ $currentTask['task_instance']->accept($this->visitorInstance);
+ }
+
+ /**
+ * Updates given task by updating the underlaying list
+ *
+ * @param $taskEntry An array with a task
+ * @return void
+ */
+ private function updateTask (array $taskEntry) {
+ // Get the key from current iteration
+ $key = $this->iteratorInstance->key();
+
+ // Get the hash from key
+ $hash = $this->listInstance->getHash($key);
+
+ // Update the entry
+ $this->listInstance->updateCurrentEntryByHash($hash, $taskEntry);
+ }
+
+ /**
+ * Registers a task with a task handler.
*
* @param $taskName A task name to register the task on
* @param $taskInstance The instance we should register as a task
public function registerTask ($taskName, Visitable $taskInstance) {
// Create the entry
$taskEntry = array(
+ // Identifier for the generateHash() method
'id' => $taskName,
- 'task_registered' => time(),
- 'task_last_active' => 0,
+ // Wether the task is started
+ 'task_started' => false,
+ // Wether the task is paused (not yet implemented)
+ 'task_paused' => false,
+ // Wether the task can be paused (not yet implemented)
+ 'task_pauseable' => true,
+ // Timestamp of registration
+ 'task_registered' => $this->getMilliTime(),
+ // Last activity timestamp
+ 'task_last_activity' => 0,
+ // Task instance itself
'task_instance' => $taskInstance,
+ // Startup delay in milliseconds
'task_startup_delay' => $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_startup_delay'),
+ // Interval time (delay) in milliseconds before this task is executed again
'task_interval_delay' => $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_interval_delay'),
);
*
* @return $tasksLeft Wether there are tasks left to handle
*/
- public final function hasTasksLeft () {
+ public function hasTasksLeft () {
// Do we have tasks there?
$tasksLeft = (($this->listInstance instanceof Listable) && ($this->listInstance->count() > 0));
$this->iteratorInstance->rewind();
} // END - if
- // Get current entry
- $taskEntry = $this->iteratorInstance->current();
-
- // Debug message
- $this->debugOutput('Handling task ' . $taskEntry['id']);
+ // Try to execute the task
+ $this->executeCurrentTask();
// Go to next entry
$this->iteratorInstance->next();
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A TaskPool iterator
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ * @todo This current implementation is not recommended, use a
+ * @todo latency-based iteration or similar approaches
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class TaskPoolIterator extends BaseIterator implements Iterator {
+ /**
+ * Key for the global list index
+ */
+ private $indexKey = 0;
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $listInstance A list of a IteratorAggregate
+ * @return $iteratorInstance An instance a Iterator class
+ */
+ public final static function createTaskPoolIterator (IteratorAggregate $listInstance) {
+ // Get new instance
+ $iteratorInstance = new TaskPoolIterator();
+
+ // Set the list
+ $iteratorInstance->setListInstance($listInstance);
+
+ // Return the prepared instance
+ return $iteratorInstance;
+ }
+
+ /**
+ * Getter for current value from group or generic
+ *
+ * @return $current Current value in iteration
+ * @throws IndexOutOfBoundsException If $indexKey is out of bounds
+ */
+ public function current () {
+ // Default is null
+ $current = null;
+
+ // Is the entry valid?
+ if (!$this->valid()) {
+ // Throw an exception here
+ throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
+ } // END - if
+
+ // Now get the entry
+ $current = $this->getListInstance()->getEntry($this->key());
+
+ // Return it
+ return $current;
+ }
+
+ /**
+ * Getter for key from group or generic
+ *
+ * @return $indexKey Current key in iteration
+ */
+ public function key () {
+ return $this->indexKey;
+ }
+
+ /**
+ * Advances to the next entry
+ *
+ * @return void
+ */
+ public function next () {
+ $this->indexKey++;
+ }
+
+ /**
+ * Rewinds to the beginning of the iteration
+ *
+ * @return void
+ */
+ public function rewind () {
+ $this->indexKey = 0;
+ }
+
+ /**
+ * Checks wether the current entry is valid (not at the end of the list)
+ *
+ * @return $isValid Wether the current entry is there
+ */
+ public function valid () {
+ // Check for total active clients and if we are not at the end
+ $isValid = ($this->key() < $this->getListInstance()->count());
+
+ // Return result
+ return $isValid;
+ }
+}
+
+// [EOF]
+?>
return $isValid;
}
+ /**
+ * Getter for hash from given hash index
+ *
+ * @param $hashIndex Index holding the hash
+ * @return $hash The hash
+ */
+ public final function getHash ($hashIndex) {
+ // Get it ...
+ $hash = $this->listIndex[$hashIndex];
+
+ // ... and return it
+ return $hash;
+ }
+
/**
* Gets an entry from given hash index
*
* @param $hashIndex The hash index to resolve the mapped entry
* @return $entry Solved entry from list
- * @throws InvalidListHashException If the solved hash index is invalid
+ * @throws InvalidListHashException If the solved hash index is invalid
*/
public function getEntry ($hashIndex) {
// Get the hash value
- $hash = $this->listIndex[$hashIndex];
+ $hash = $this->getHash($hashIndex);
// Is the hash valid?
if (!$this->isHashValid($hash)) {
// Return it
return $entry;
}
+
+ /**
+ * Updates the given entry by hash with given array
+ *
+ * @param $hash Hash for this entry
+ * @param $entryArray Array with entry we should update
+ * @return void
+ * @throws InvalidListHashException If the solved hash index is invalid
+ */
+ public function updateCurrentEntryByHash ($hash, array $entryArray) {
+ // Is the hash valid?
+ if (!$this->isHashValid($hash)) {
+ // Throw an exception here, hashIndex is unknown at this point
+ throw new InvalidListHashException(array($this, $hash, -999), self::EXCEPTION_INVALID_HASH);
+ }
+
+ // Set the entry
+ $this->listEntries[$hash] = $entryArray;
+ }
}
//
public function accept (Visitor $visitorInstance) {
$this->partialStub('Please implement this method. visitor='.$visitorInstance->__toString());
}
+
+ /**
+ * Executes the task
+ *
+ * @return void
+ */
+ public function execute () {
+ $this->partialStub('Unimplemented task.');
+ }
}
// [EOF]
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class IdleLoopTask extends BaseTask implements Visitable {
+class IdleLoopTask extends BaseTask implements Visitable, Taskable {
/**
* Protected constructor
*
*
* @param $visitorInstance An instance of a Visitor class
* @return void
- * @todo 0%
*/
public function accept (Visitor $visitorInstance) {
- $this->partialStub('Please implement this method. visitor='.$visitorInstance->__toString());
+ // Visit this task
+ $visitorInstance->visitTask($this);
+ }
+
+ /**
+ * Executes the task
+ *
+ * @return void
+ */
+ public function execute () {
+ // Idle here a little (2 milliseconds)
+ $this->idle(2);
}
}
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A ??? shutdown visitor
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class Shutdown???Visitor extends BaseVisitor implements PoolVisitor {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $visitorInstance An instance a Visitorable class
- */
- public final static function createShutdown???Visitor () {
- // Get new instance
- $visitorInstance = new Shutdown???Visitor();
-
- // Return the prepared instance
- return $visitorInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A ListenerPool shutdown visitor
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ShutdownListenerPoolVisitor extends BaseVisitor implements PoolVisitor {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $visitorInstance An instance a Visitorable class
- */
- public final static function createShutdownListenerPoolVisitor () {
- // Get new instance
- $visitorInstance = new ShutdownListenerPoolVisitor();
-
- // Return the prepared instance
- return $visitorInstance;
- }
-
- /**
- * Visits the given pool instance
- *
- * @param $poolInstance A Poolable instance
- * @return void
- */
- public function visitPool (Poolable $poolInstance) {
- // Debug message
- $this->debugOutput('VISITOR: Visit of ' . $poolInstance->__toString() . ' - START');
-
- // Pre-shutdown the pool
- $poolInstance->preShutdown();
-
- // Debug message
- $this->debugOutput('VISITOR: Visit of ' . $poolInstance->__toString() . ' - FINISHED');
- }
-}
-
-//
-?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An ActiveTask visitor
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, QueryVisitor, PoolVisitor {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set visitor mode
+ $this->setVisitorMode('task');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $visitorInstance An instance a Visitorable class
+ */
+ public final static function createActiveTaskVisitor () {
+ // Get new instance
+ $visitorInstance = new ActiveTaskVisitor();
+
+ // Return the prepared instance
+ return $visitorInstance;
+ }
+
+ /**
+ * Visits the given pool instance
+ *
+ * @param $poolInstance A Taskable instance
+ * @return void
+ */
+ public function visitTask (Taskable $taskInstance) {
+ // Execute the task from this visitor
+ $taskInstance->execute();
+ }
+
+ /**
+ * Query visitor method for active tasks
+ *
+ * @param $queryInstance A Queryable instance
+ * @return void
+ */
+ public function visitQuery (Queryable $queryInstance) {
+ // Handle all queries
+ $queryInstance->handleQueries();
+ }
+
+ /**
+ * Pool visitor method for active tasks
+ *
+ * @param $poolInstance A Poolable instance
+ * @return void
+ */
+ public function visitPool (Poolable $poolInstance) {
+ // We don't need to visit a pool as an active task because a pool can
+ // never become a task.
+ }
+}
+
+// [EOF]
+?>