| 24 | namespace 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 | { |
nothing calls this directly
no outgoing calls
no test coverage detected