diff --git a/sensors/Sensor.cpp b/sensors/Sensor.cpp index 73a9567..991e723 100644 --- a/sensors/Sensor.cpp +++ b/sensors/Sensor.cpp @@ -83,8 +83,8 @@ void Sensor::batch(int32_t samplingPeriodNs) { } void Sensor::activate(bool enable) { + std::lock_guard lock(mRunMutex); if (mIsEnabled != enable) { - std::unique_lock lock(mRunMutex); mIsEnabled = enable; mWaitCV.notify_all(); } @@ -158,8 +158,8 @@ std::vector Sensor::readEvents() { } void Sensor::setOperationMode(OperationMode mode) { + std::lock_guard lock(mRunMutex); if (mMode != mode) { - std::unique_lock lock(mRunMutex); mMode = mode; mWaitCV.notify_all(); }