diff options
| author | Per Larsson <[email protected]> | 2021-09-16 21:19:14 +0200 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-09-16 21:19:14 +0200 |
| commit | cae9f697a13840eb87cb9f6fc32eb80e3a65b29a (patch) | |
| tree | 721af351316d5a1fe2ac022fad2a4e9017b043ae /zencore/include | |
| parent | zcache - minor cleanup. (diff) | |
| parent | Merge branch 'main' of https://github.com/EpicGames/zen (diff) | |
| download | zen-cae9f697a13840eb87cb9f6fc32eb80e3a65b29a.tar.xz zen-cae9f697a13840eb87cb9f6fc32eb80e3a65b29a.zip | |
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/logging.h | 7 | ||||
| -rw-r--r-- | zencore/include/zencore/thread.h | 27 |
2 files changed, 33 insertions, 1 deletions
diff --git a/zencore/include/zencore/logging.h b/zencore/include/zencore/logging.h index 8e6b3a244..e98509bf8 100644 --- a/zencore/include/zencore/logging.h +++ b/zencore/include/zencore/logging.h @@ -80,3 +80,10 @@ using zen::Log; using namespace std::literals; \ Log().critical(fmtstr##sv, __VA_ARGS__); \ } while (false) + +#define ZEN_CONSOLE(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + ConsoleLog().info(fmtstr##sv, __VA_ARGS__); \ + } while (false) diff --git a/zencore/include/zencore/thread.h b/zencore/include/zencore/thread.h index b18da6031..0e34d6518 100644 --- a/zencore/include/zencore/thread.h +++ b/zencore/include/zencore/thread.h @@ -8,6 +8,8 @@ # include <shared_mutex> #endif +#include <vector> + namespace zen { /** @@ -93,6 +95,7 @@ public: ZENCORE_API void Set(); ZENCORE_API void Reset(); ZENCORE_API bool Wait(int TimeoutMs = -1); + ZENCORE_API void Close(); protected: explicit Event(void* EventHandle) : m_EventHandle(EventHandle) {} @@ -125,7 +128,7 @@ private: }; /** Basic process abstraction - */ + */ class ProcessHandle { public: @@ -150,6 +153,28 @@ private: int m_Pid = 0; }; +/** Process monitor - monitors a list of running processes via polling + + Intended to be used to monitor a set of "sponsor" processes, where + we need to determine when none of them remain alive + + */ + +class ProcessMonitor +{ +public: + ProcessMonitor(); + ~ProcessMonitor(); + + ZENCORE_API bool IsRunning(); + ZENCORE_API void AddPid(int Pid); + ZENCORE_API bool IsActive() const; + +private: + mutable RwLock m_Lock; + std::vector<void*> m_ProcessHandles; +}; + ZENCORE_API bool IsProcessRunning(int pid); ZENCORE_API int GetCurrentProcessId(); |