mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-07-03 00:54:38 -05:00
Expose API to notify about variable value change
This commit is contained in:
parent
89ffa6611c
commit
28a0ca8fcf
|
|
@ -108,16 +108,20 @@ std::optional<int> Variable::IntValue() const
|
|||
|
||||
void Variable::SetValue(const std::string &value)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
_previousValue = _value;
|
||||
_value = value;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
_previousValue = _value;
|
||||
_value = value;
|
||||
|
||||
UpdateLastUsed();
|
||||
if (_previousValue != _value) {
|
||||
_lastChanged = std::chrono::high_resolution_clock::now();
|
||||
++_valueChangeCount;
|
||||
UpdateLastUsed();
|
||||
if (_previousValue != _value) {
|
||||
_lastChanged =
|
||||
std::chrono::high_resolution_clock::now();
|
||||
++_valueChangeCount;
|
||||
}
|
||||
setLastVariableChangeTime();
|
||||
}
|
||||
setLastVariableChangeTime();
|
||||
_cv.notify_all();
|
||||
}
|
||||
|
||||
void Variable::SetValue(double value)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "item-selection-helpers.hpp"
|
||||
#include "resizing-text-edit.hpp"
|
||||
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <obs-data.h>
|
||||
#include <optional>
|
||||
|
|
@ -43,6 +44,11 @@ public:
|
|||
std::optional<uint64_t> GetSecondsSinceLastUse() const;
|
||||
std::optional<uint64_t> GetSecondsSinceLastChange() const;
|
||||
void MarkAsUsed() const;
|
||||
EXPORT std::condition_variable &GetCV() { return _cv; }
|
||||
EXPORT std::unique_lock<std::mutex> GetCVLock()
|
||||
{
|
||||
return std::unique_lock<std::mutex>(_cvMutex);
|
||||
}
|
||||
|
||||
private:
|
||||
SaveAction _saveAction = SaveAction::DONT_SAVE;
|
||||
|
|
@ -53,6 +59,8 @@ private:
|
|||
mutable std::chrono::high_resolution_clock::time_point _lastUsed;
|
||||
mutable std::chrono::high_resolution_clock::time_point _lastChanged;
|
||||
mutable std::mutex _mutex;
|
||||
std::mutex _cvMutex;
|
||||
std::condition_variable _cv;
|
||||
|
||||
void UpdateLastUsed() const;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user