-class Action {
-public:
- Action();
- Action(ModelPtr model, double cost, bool failed);
- virtual ~Action();
-
- s_xbt_swag_hookup_t p_stateHookup;
-
- e_surf_action_state_t getState(); /**< get the state*/
- virtual void setState(e_surf_action_state_t state); /**< Change state*/
- double getStartTime(); /**< Return the start time of an action */
- double getFinishTime(); /**< Return the finish time of an action */
- void setData(void* data);
-
- void ref();
- virtual int unref(); /**< Specify that we don't use that action anymore. Returns true if the action was destroyed and false if someone still has references on it. */
- virtual void cancel(); /**< Cancel a running action */
- virtual void recycle(); /**< Recycle an action */
-
- virtual void suspend()=0; /**< Suspend an action */
- virtual void resume()=0; /**< Resume a suspended action */
- virtual bool isSuspended()=0; /**< Return whether an action is suspended */
- virtual void setMaxDuration(double duration)=0; /**< Set the max duration of an action*/
- virtual void setPriority(double priority)=0; /**< Set the priority of an action */
-#ifdef HAVE_TRACING
- void setCategory(const char *category); /**< Set the category of an action */
-#endif
- virtual double getRemains(); /**< Get the remains of an action */
-#ifdef HAVE_LATENCY_BOUND_TRACKING
- int getLatencyLimited(); /**< Return 1 if action is limited by latency, 0 otherwise */
-#endif
-
- xbt_swag_t p_stateSet;
-
- double m_priority; /**< priority (1.0 by default) */
- double m_bound; /**< the capping of the CPU use */
- bool m_failed;
- double m_start; /**< start time */
- double m_finish; /**< finish time : this is modified during the run and fluctuates until the task is completed */
- double m_remains; /**< How much of that cost remains to be done in the currently running task */
- #ifdef HAVE_LATENCY_BOUND_TRACKING
- int m_latencyLimited; /**< Set to 1 if is limited by latency, 0 otherwise */
- #endif
- double m_maxDuration; /*< max_duration (may fluctuate until the task is completed) */
- char *p_category; /**< tracing category for categorized resource utilization monitoring */
- int m_cost;
- void *p_data; /**< for your convenience */
-protected:
- ModelPtr p_model;
- int m_refcount;
-#ifdef HAVE_TRACING
-#endif
-
-private:
- int resourceUsed(void *resource_id);
- /* Share the resources to the actions and return in how much time
- the next action may terminate */
- double shareResources(double now);
- /* Update the actions' state */
- void updateActionsState(double now, double delta);
- void updateResourceState(void *id, tmgr_trace_event_t event_type,
- double value, double time);
-
- xbt_swag_t p_modifiedSet;
- xbt_heap_t p_actionHeap;
- int m_selectiveUpdate;
-};
-
-//FIXME:REMOVE
-void surf_action_lmm_update_index_heap(void *action, int i);
-
-class ActionLmm: virtual public Action {
-public:
- ActionLmm() : m_suspended(false) {
- p_actionListHookup.prev = 0;
- p_actionListHookup.next = 0;
- m_lastUpdate = 0;
- m_lastValue = 0;
- };
- ActionLmm(ModelPtr /*model*/, double /*cost*/, bool /*failed*/) : m_suspended(false) {
- p_actionListHookup.prev = 0;
- p_actionListHookup.next = 0;
- m_lastUpdate = 0;
- m_lastValue = 0;
- };
-
- virtual void updateRemainingLazy(double now);
- void heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat);
- void heapRemove(xbt_heap_t heap);
- double getRemains(); /**< Get the remains of an action */
- void updateIndexHeap(int i);
-
- virtual int unref();
- void cancel();
- void suspend();
- void resume();
- bool isSuspended();
- void setMaxDuration(double duration);
- void setPriority(double priority);
- void gapRemove();
-
- lmm_variable_t p_variable;
- s_xbt_swag_hookup_t p_actionListHookup;
- int m_indexHeap;
- double m_lastUpdate;
- double m_lastValue;
- enum heap_action_type m_hat;
- int m_suspended;
-};
-