sampling_algorithm.h 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. #ifndef __SAMPLING_ALGORITHM
  2. #define __SAMPLING_ALGORITHM
  3. #include "fixed_types.h"
  4. #include "subsecond_time.h"
  5. class SamplingManager;
  6. // Base class for algorithms that decide how to sample
  7. // - an algorithm receives a periodic callback, both while in detailed and in fastforward mode
  8. // - during each callback the algorithm can examine system state, and decide to switch modes
  9. // by calling SamplingManager::{enable|disable}FastForward
  10. // - the algorithm should perform the proper setup (configure each core's setCurrentCPI)
  11. // so time can be maintained while fast-forwarding
  12. class SamplingAlgorithm
  13. {
  14. protected:
  15. SamplingManager *m_sampling_manager;
  16. public:
  17. SamplingAlgorithm(SamplingManager *sampling_manager) : m_sampling_manager(sampling_manager) {}
  18. virtual ~SamplingAlgorithm() {}
  19. virtual void callbackDetailed(SubsecondTime now) = 0;
  20. virtual void callbackFastForward(SubsecondTime now, bool in_warmup) = 0;
  21. static SamplingAlgorithm* create(SamplingManager *sampling_manager);
  22. };
  23. #endif /* __SAMPLING_ALGORITHM */