MCPcopy Create free account
hub / github.com/Apache553/SubtitleFontHelper / SingleInstanceLock

Class SingleInstanceLock

SubtitleFontAutoLoaderDaemon/Main.cpp:26–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24namespace sfh
25{
26 class SingleInstanceLock
27 {
28 private:
29 wil::unique_mutex m_mutex;
30 public:
31 SingleInstanceLock()
32 {
33 std::wstring mutexName = LR"_(SubtitleFontAutoLoaderMutex-)_";
34 mutexName += GetCurrentProcessUserSid();
35 m_mutex.create(mutexName.c_str());
36 if (WaitForSingleObject(m_mutex.get(), 0) != WAIT_OBJECT_0)
37 throw std::runtime_error("Another instance is running!");
38 }
39
40 ~SingleInstanceLock()
41 {
42 m_mutex.ReleaseMutex();
43 }
44 };
45
46 class Daemon : public IDaemon
47 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected