diff options
| author | Stefan Boberg <[email protected]> | 2021-08-09 21:10:11 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-08-09 21:10:11 +0200 |
| commit | 8f05d82714650d200f353b466a6a8328a691a6f7 (patch) | |
| tree | b048031314560f29b7abe09c9050d2b9a4959bcd /zenutil/include | |
| parent | Changed logic so that the shutdown monitoring thread is spun up in non-test m... (diff) | |
| download | zen-8f05d82714650d200f353b466a6a8328a691a6f7.tar.xz zen-8f05d82714650d200f353b466a6a8328a691a6f7.zip | |
Extended ZenServerInstance life cycle management
Diffstat (limited to 'zenutil/include')
| -rw-r--r-- | zenutil/include/zenserverprocess.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/zenutil/include/zenserverprocess.h b/zenutil/include/zenserverprocess.h index d2101c8e8..d0093537e 100644 --- a/zenutil/include/zenserverprocess.h +++ b/zenutil/include/zenserverprocess.h @@ -2,9 +2,11 @@ #pragma once +#include <zencore/enumflags.h> #include <zencore/thread.h> #include <spdlog/spdlog.h> +#include <gsl/gsl-lite.hpp> #include <atomic> #include <filesystem> @@ -36,7 +38,8 @@ struct ZenServerInstance ZenServerInstance(ZenServerEnvironment& TestEnvironment); ~ZenServerInstance(); - void SignalShutdown() { m_ShutdownEvent.Set(); } + void Shutdown(); + void SignalShutdown(); void WaitUntilReady(); [[nodiscard]] bool WaitUntilReady(int Timeout); void EnableTermination() { m_Terminate = true; } @@ -49,6 +52,7 @@ struct ZenServerInstance } void SpawnServer(int BasePort = 0); + void AttachToRunningServer(int BasePort = 0); private: @@ -59,6 +63,8 @@ private: bool m_Terminate = false; std::filesystem::path m_TestDir; bool m_MeshEnabled = false; + + void CreateShutdownEvent(int BasePort); }; /** Shared system state @@ -79,11 +85,19 @@ public: { std::atomic<uint32_t> Pid; std::atomic<uint16_t> ListenPort; - uint16_t Flags; + std::atomic<uint16_t> Flags; uint8_t SessionId[12]; uint8_t Padding[12]; + enum class FlagsEnum : uint16_t + { + kShutdownPlease = 1 << 0 + }; + + FRIEND_ENUM_CLASS_FLAGS(FlagsEnum); + void Reset(); + void SignalShutdownRequest(); }; static_assert(sizeof(ZenServerEntry) == 32); |