#ifndef __AMASS_LEAKTRACER_H__ #define __AMASS_LEAKTRACER_H__ #include <chrono> #include <string> #include <thread> class LeakTracer { public: LeakTracer(const std::string &path, const std::string &applicationName); ~LeakTracer(); template <class Rep, class Period> void start(const std::chrono::duration<Rep, Period> &intervals) { if (m_exit) { m_exit = false; m_thread = std::thread(&LeakTracer::run, this); } m_intervals = std::chrono::duration_cast<std::chrono::milliseconds>(intervals); } void stop(); protected: void run(); private: bool m_exit = true; std::string m_path; std::string m_applicationName; std::chrono::milliseconds m_intervals; std::thread m_thread; }; #endif // __AMASS_LEAKTRACER_H__