mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-12 04:11:06 -05:00
Refactor locking of macro segments
This should avoid crashes when actions or conditions are performed in parallel to the main macro loop and will improve the UI responsiveness in some scenarios
This commit is contained in:
@@ -20,4 +20,36 @@ std::unique_lock<std::mutex> *GetLoopLock()
|
||||
return GetSwitcherLoopLock();
|
||||
}
|
||||
|
||||
PerInstanceMutex::PerInstanceMutex() {}
|
||||
|
||||
PerInstanceMutex::~PerInstanceMutex(){};
|
||||
|
||||
PerInstanceMutex::PerInstanceMutex(const PerInstanceMutex &) {}
|
||||
|
||||
PerInstanceMutex &PerInstanceMutex::operator=(const PerInstanceMutex &)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
PerInstanceMutex::operator std::mutex &()
|
||||
{
|
||||
return _mtx;
|
||||
}
|
||||
|
||||
PerInstanceMutex::operator const std::mutex &() const
|
||||
{
|
||||
return _mtx;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> Lockable::Lock()
|
||||
{
|
||||
return std::lock_guard<std::mutex>(_mtx);
|
||||
}
|
||||
|
||||
void Lockable::WithLock(const std::function<void()> &func)
|
||||
{
|
||||
const auto lock = Lock();
|
||||
func();
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
|
||||
Reference in New Issue
Block a user