// resource manager // // Date: 2024-02-25 // // Resources in monitoring: memory #pragma once #include #include // #define USE_MONITOR_THREAD class resource_mgr { volatile bool run_ = true; volatile bool monitor_ = false; uint64_t mem_limit_ = SIZE_MB(2500); volatile uint64_t mem_now_ = 0; std::unique_ptr thread_; void thread_monitor(void); public: resource_mgr(); ~resource_mgr(); static std::string task_type(_task task); public: void start(void); void stop(void); void set_memory_limit(uint64_t max_size = SIZE_GB(2)); bool is_resource_enable(_task task, bool wait = false, int to_ms = 0); };