Skip to content

Commit

Permalink
add platform::get_process_id
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Dec 12, 2024
1 parent 8e6fb1d commit 913f942
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/util/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ void platform::sleep(size_t millis) {
// Reset the timer resolution back to the system default
timeEndPeriod(periodMin);
}
#else

int platform::get_process_id() {
return GetCurrentProcessId();
}

#else // _WIN32

#include <unistd.h>

void platform::configure_encoding() {
}
Expand All @@ -74,7 +81,11 @@ std::string platform::detect_locale() {
void platform::sleep(size_t millis) {
std::this_thread::sleep_for(std::chrono::milliseconds(millis));
}
#endif

int platform::get_process_id() {
return getpid();
}
#endif // _WIN32

void platform::open_folder(const std::filesystem::path& folder) {
if (!std::filesystem::is_directory(folder)) {
Expand Down
1 change: 1 addition & 0 deletions src/util/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ namespace platform {
void open_folder(const std::filesystem::path& folder);
/// Makes the current thread sleep for the specified amount of milliseconds.
void sleep(size_t millis);
int get_process_id();
}

0 comments on commit 913f942

Please sign in to comment.