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

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

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

parents d966a695 7ea287a0
Loading
Loading
Loading
Loading
+11 −13
Original line number Original line Diff line number Diff line
@@ -1626,19 +1626,17 @@ void SensorService::onProximityActiveLocked(bool isActive) {
}
}


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


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