Wildmeshing Toolkit
Loading...
Searching...
No Matches
HeapTrimmer.hpp
1#pragma once
2
3#include <chrono>
4#include <condition_variable>
5#include <mutex>
6#include <thread>
7
8namespace wmtk {
9
32{
33public:
34 explicit HeapTrimmer(std::chrono::milliseconds period = std::chrono::milliseconds(500));
36
37 HeapTrimmer(const HeapTrimmer&) = delete;
38 HeapTrimmer& operator=(const HeapTrimmer&) = delete;
39
40private:
41 std::chrono::milliseconds m_period;
42 std::mutex m_mutex;
43 std::condition_variable m_wake;
44 bool m_stop = false;
45 std::thread m_thread;
46};
47
48} // namespace wmtk
While alive, periodically hands memory the program has freed back to the system.
Definition HeapTrimmer.hpp:32