Adding NS3 FDNetDevice RM
[nepi.git] / src / nepi / execution / scheduler.py
index cbd9874..7448e5c 100644 (file)
@@ -21,15 +21,26 @@ import itertools
 import heapq
 
 class TaskStatus:
+    """ Execution state of the Task
+    """
     NEW = 0
     DONE = 1
     ERROR = 2
 
 class Task(object):
-    """ This class is to define a task, that is represented by an id,
-    an execution time 'timestamp' and an action 'callback """
+    """ A Task represents an operation to be executed by the 
+    ExperimentController scheduler
+    """
 
     def __init__(self, timestamp, callback):
+        """
+        :param timestamp: Future execution date of the operation
+        :type timestamp: str
+
+        :param callback: A function to invoke in order to execute the operation
+        :type callback: function
+
+        """ 
         self.id = None 
         self.timestamp = timestamp
         self.callback = callback
@@ -37,7 +48,7 @@ class Task(object):
         self.status = TaskStatus.NEW
 
 class HeapScheduler(object):
-    """ Create a Heap Scheduler.
+    """ Create a Heap Scheduler
 
     .. note::
 
@@ -59,9 +70,9 @@ class HeapScheduler(object):
         return self._valid
 
     def schedule(self, task):
-        """ Add the task 'task' in the heap of the scheduler
+        """ Add a task to the queue ordered by task.timestamp and arrival order
 
-        :param task: task that need to be schedule
+        :param task: task to schedule
         :type task: task
         """
         if task.id == None:
@@ -73,10 +84,11 @@ class HeapScheduler(object):
         return task
 
     def remove(self, tid):
-        """ Remove a task form the heap
+        """ Remove a task form the queue
 
-        :param tid: Id of the task that need to be removed
+        :param tid: Id of the task to be removed
         :type tid: int
+
         """
         try:
             self._valid.remove(tid)
@@ -84,8 +96,7 @@ class HeapScheduler(object):
             pass
 
     def next(self):
-        """ Get the next task in the scheduler
-
+        """ Get the next task in the queue by timestamp and arrival order
         """
         while self._queue:
             try: