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

Commit 45c44c99 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Switch away from std::async for proximity-active callback." into sc-dev am: c6ad94b6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/14965036

Change-Id: I8fc63855412fd3d061c8d0f1e61e9072373d14af
parents c3da3fa8 c6ad94b6
Loading
Loading
Loading
Loading
+11 −13
Original line number Diff line number Diff line
@@ -1626,19 +1626,17 @@ void SensorService::onProximityActiveLocked(bool isActive) {
}

void SensorService::notifyProximityStateLocked(
        const std::vector<sp<ProximityActiveListener>>& listnrs) {
    std::async(
        std::launch::async,
        [](uint64_t mySeq, bool isActive, std::vector<sp<ProximityActiveListener>> listeners) {
        const std::vector<sp<ProximityActiveListener>>& listeners) {
    const bool isActive = mProximityActiveCount > 0;
    const uint64_t mySeq = ++curProxCallbackSeq;
    std::thread t([isActive, mySeq, listenersCopy = listeners]() {
        while (completedCallbackSeq.load() != mySeq - 1)
            std::this_thread::sleep_for(1ms);
            for (auto& listener : listeners)
        for (auto& listener : listenersCopy)
            listener->onProximityActive(isActive);
        completedCallbackSeq++;
        },
        ++curProxCallbackSeq, mProximityActiveCount > 0,
        listnrs /* (this is meant to be a copy) */
    );
    });
    t.detach();
}

status_t SensorService::addProximityActiveListener(const sp<ProximityActiveListener>& callback) {