Loading services/vibratorservice/VibratorCallbackScheduler.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -87,13 +87,13 @@ void CallbackScheduler::loop() { lock.lock(); } if (mQueue.empty()) { // Wait until a new callback is scheduled. mCondition.wait(mMutex); // Wait until a new callback is scheduled or destructor was called. mCondition.wait(lock, [this] { return mFinished || !mQueue.empty(); }); } else { // Wait until next callback expires, or a new one is scheduled. // Wait until next callback expires or a new one is scheduled. // Use the monotonic steady clock to wait for the measured delay interval via wait_for // instead of using a wall clock via wait_until. mCondition.wait_for(mMutex, mQueue.top().getWaitForExpirationDuration()); mCondition.wait_for(lock, mQueue.top().getWaitForExpirationDuration()); } } } Loading services/vibratorservice/test/test_utils.h +5 −3 Original line number Diff line number Diff line Loading @@ -90,13 +90,15 @@ public: TestCounter(int32_t init = 0) : mMutex(), mCondVar(), mCount(init) {} int32_t get() { std::unique_lock<std::mutex> lock(mMutex); std::lock_guard<std::mutex> lock(mMutex); return mCount; } void increment() { std::unique_lock<std::mutex> lock(mMutex); { std::lock_guard<std::mutex> lock(mMutex); mCount += 1; } mCondVar.notify_all(); } Loading Loading
services/vibratorservice/VibratorCallbackScheduler.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -87,13 +87,13 @@ void CallbackScheduler::loop() { lock.lock(); } if (mQueue.empty()) { // Wait until a new callback is scheduled. mCondition.wait(mMutex); // Wait until a new callback is scheduled or destructor was called. mCondition.wait(lock, [this] { return mFinished || !mQueue.empty(); }); } else { // Wait until next callback expires, or a new one is scheduled. // Wait until next callback expires or a new one is scheduled. // Use the monotonic steady clock to wait for the measured delay interval via wait_for // instead of using a wall clock via wait_until. mCondition.wait_for(mMutex, mQueue.top().getWaitForExpirationDuration()); mCondition.wait_for(lock, mQueue.top().getWaitForExpirationDuration()); } } } Loading
services/vibratorservice/test/test_utils.h +5 −3 Original line number Diff line number Diff line Loading @@ -90,13 +90,15 @@ public: TestCounter(int32_t init = 0) : mMutex(), mCondVar(), mCount(init) {} int32_t get() { std::unique_lock<std::mutex> lock(mMutex); std::lock_guard<std::mutex> lock(mMutex); return mCount; } void increment() { std::unique_lock<std::mutex> lock(mMutex); { std::lock_guard<std::mutex> lock(mMutex); mCount += 1; } mCondVar.notify_all(); } Loading