Add additional sync-helpers to reduce dependencies to switcher-data

This commit is contained in:
WarmUpTill 2023-12-24 01:02:32 +01:00 committed by WarmUpTill
parent 84dd5e6930
commit dd78b03a28
3 changed files with 19 additions and 0 deletions

View File

@ -14,6 +14,11 @@ std::mutex *GetSwitcherMutex()
return switcher ? &switcher->m : nullptr;
}
std::unique_lock<std::mutex> *GetSwitcherLoopLock()
{
return switcher ? switcher->mainLoopLock : nullptr;
}
bool VerboseLoggingEnabled()
{
return switcher ? switcher->verbose : false;

View File

@ -3,9 +3,21 @@
namespace advss {
std::mutex *GetSwitcherMutex();
std::unique_lock<std::mutex> *GetSwitcherLoopLock();
std::mutex *GetMutex()
{
return GetSwitcherMutex();
}
std::lock_guard<std::mutex> LockContext()
{
return std::lock_guard<std::mutex>(*GetSwitcherMutex());
}
std::unique_lock<std::mutex> *GetLoopLock()
{
return GetSwitcherLoopLock();
}
} // namespace advss

View File

@ -3,6 +3,8 @@
namespace advss {
[[nodiscard]] std::mutex *GetMutex();
[[nodiscard]] std::lock_guard<std::mutex> LockContext();
[[nodiscard]] std::unique_lock<std::mutex> *GetLoopLock();
} // namespace advss