Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc324f7e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix flaky GNSS VTS" into main

parents 49d05dec 23e78269
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -146,15 +146,18 @@ void GnssMeasurementInterface::stop() {
    mIsActive = false;
    mGnss->setGnssMeasurementEnabled(false);
    mThreadBlocker.notify();
    for (auto iter = mThreads.begin(); iter != mThreads.end(); ++iter) {
    for (auto iter = mThreads.begin(); iter != mThreads.end();) {
        if (iter->joinable()) {
            mFutures.push_back(std::async(std::launch::async, [this, iter] {
                iter->join();
                mThreads.erase(iter);
            // Store the thread object by value
            std::thread threadToMove = std::move(*iter);

            mFutures.push_back(std::async(std::launch::async,
                                          [threadToMove = std::move(threadToMove)]() mutable {
                                              ALOGD("joining thread");
                                              threadToMove.join();
                                          }));
        } else {
            mThreads.erase(iter);
        }
        iter = mThreads.erase(iter);
    }
}

+10 −7
Original line number Diff line number Diff line
@@ -90,15 +90,18 @@ void GnssNavigationMessageInterface::stop() {
    ALOGD("stop");
    mIsActive = false;
    mThreadBlocker.notify();
    for (auto iter = mThreads.begin(); iter != mThreads.end(); ++iter) {
    for (auto iter = mThreads.begin(); iter != mThreads.end();) {
        if (iter->joinable()) {
            mFutures.push_back(std::async(std::launch::async, [this, iter] {
                iter->join();
                mThreads.erase(iter);
            // Store the thread object by value
            std::thread threadToMove = std::move(*iter);

            mFutures.push_back(std::async(std::launch::async,
                                          [threadToMove = std::move(threadToMove)]() mutable {
                                              ALOGD("joining thread");
                                              threadToMove.join();
                                          }));
        } else {
            mThreads.erase(iter);
        }
        iter = mThreads.erase(iter);
    }
}