diff options
| author | Dan Engelbrecht <[email protected]> | 2023-08-17 22:52:28 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-08-17 22:52:28 +0200 |
| commit | dc320d6bfe81f149e8276caabcd165a931711ae7 (patch) | |
| tree | 4fd245d817876f15e90eb30f6577d4550c76f8fc /src/zenutil/include | |
| parent | single thread async cache log (#361) (diff) | |
| download | zen-dc320d6bfe81f149e8276caabcd165a931711ae7.tar.xz zen-dc320d6bfe81f149e8276caabcd165a931711ae7.zip | |
Cache process handles for FormatPackageMessage (#360)
Diffstat (limited to 'src/zenutil/include')
| -rw-r--r-- | src/zenutil/include/zenutil/openprocesscache.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/zenutil/include/zenutil/openprocesscache.h b/src/zenutil/include/zenutil/openprocesscache.h new file mode 100644 index 000000000..3db4e0b42 --- /dev/null +++ b/src/zenutil/include/zenutil/openprocesscache.h @@ -0,0 +1,39 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#pragma once + +#include <zencore/thread.h> +#include <zencore/uid.h> + +#include <thread> +#include <unordered_map> + +namespace zen { + +class OpenProcessCache +{ +public: + OpenProcessCache(); + ~OpenProcessCache(); + + void* GetProcessHandle(Oid SessionId, int ProcessPid); + +private: +#if ZEN_PLATFORM_WINDOWS + struct Process + { + int ProcessPid; + void* ProcessHandle; + }; + + void GCHandles(); + void GcWorker(); + + RwLock m_SessionsLock; + std::unordered_map<Oid, Process, Oid::Hasher> m_Sessions; + std::thread m_GcThread; + Event m_GcExitEvent; +#endif // ZEN_PLATFORM_WINDOWS +}; + +} // namespace zen |