-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows us to properly clean up the thread and popen when exiting
- Loading branch information
1 parent
0849ae4
commit 9411963
Showing
3 changed files
with
80 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <sys/stat.h> | ||
#include <thread> | ||
#include <nlohmann/json.hpp> | ||
#include <filesystem.h> | ||
#include <inttypes.h> | ||
#include <mesa/util/os_time.h> | ||
#include <spdlog/spdlog.h> | ||
#include "gpu.h" | ||
#include "hud_elements.h" | ||
|
||
using json = nlohmann::json; | ||
namespace fs = ghc::filesystem; | ||
|
||
class Intel { | ||
private: | ||
bool init = false; | ||
bool runtime = false; | ||
bool stop = false; | ||
struct gpuInfo gpu_info_intel {}; | ||
FILE* fdinfo; | ||
struct stat stat_buffer; | ||
std::thread thread; | ||
|
||
FILE* find_fd(); | ||
void intel_gpu_thread(); | ||
uint64_t get_gpu_time(); | ||
void get_fdinfo(); | ||
|
||
public: | ||
Intel() { | ||
if (stat("/run/pressure-vessel", &stat_buffer) == 0) | ||
runtime = true; | ||
|
||
fdinfo = find_fd(); | ||
thread = std::thread(&Intel::intel_gpu_thread, this); | ||
} | ||
|
||
void update() { | ||
get_fdinfo(); | ||
gpu_info = gpu_info_intel; | ||
} | ||
|
||
~Intel(){ | ||
stop = true; | ||
thread.join(); | ||
} | ||
}; | ||
|
||
extern std::unique_ptr<Intel> intel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters