sc_runner.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Timer Service for SCTUnit
  3. */
  4. #ifndef SC_TIMER_SERVICE_H_
  5. #define SC_TIMER_SERVICE_H_
  6. #include <list>
  7. #include "sc_types.h"
  8. #include "StatemachineInterface.h"
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. class SctUnitRunner {
  13. public:
  14. SctUnitRunner(StatemachineInterface * statemachine, bool event_driven, sc_integer cycle_period);
  15. virtual ~SctUnitRunner(){};
  16. void proceed_time(sc_integer time_ms);
  17. void proceed_cycles(sc_integer cycles);
  18. virtual void cancel();
  19. private:
  20. class SctTimer;
  21. StatemachineInterface * statemachine;
  22. bool event_driven;
  23. sc_integer cycle_period;
  24. sc_integer current_time_ms;
  25. std::list<SctTimer> timer_queue;
  26. void insert_timer(SctTimer timer);
  27. };
  28. class SctUnitRunner::SctTimer {
  29. friend class SctUnitRunner;
  30. public:
  31. SctTimer(sc_integer time_ms, bool periodic, sc_eventid evid, sc_integer priority, sc_boolean is_runcycle);
  32. ~SctTimer(){}
  33. sc_integer compare(SctTimer * other);
  34. private:
  35. sc_integer rel_time_ms;
  36. sc_integer abs_time_ms;
  37. sc_boolean periodic;
  38. sc_eventid pt_evid;
  39. sc_integer priority;
  40. sc_boolean is_runcycle;
  41. };
  42. #ifdef __cplusplus
  43. }
  44. #endif
  45. #endif /* SC_TIMER_SERVICE_H_ */