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

Commit 13968742 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Reduce lock thrashing in native Looper." into gingerbread

parents 8d978cdd ed242de3
Loading
Loading
Loading
Loading
+38 −32
Original line number Diff line number Diff line
@@ -184,8 +184,7 @@ int Looper::pollInner(int timeoutMillis) {
#if DEBUG_POLL_AND_WAKE
    LOGD("%p ~ pollOnce - handling events from %d fds", this, eventCount);
#endif
    { // acquire lock
        AutoMutex _l(mLock);
    bool acquiredLock = false;
    for (int i = 0; i < eventCount; i++) {
        int fd = eventItems[i].data.fd;
        uint32_t epollEvents = eventItems[i].events;
@@ -203,6 +202,11 @@ int Looper::pollInner(int timeoutMillis) {
                LOGW("Ignoring unexpected epoll events 0x%x on wake read pipe.", epollEvents);
            }
        } else {
            if (! acquiredLock) {
                mLock.lock();
                acquiredLock = true;
            }

            ssize_t requestIndex = mRequests.indexOfKey(fd);
            if (requestIndex >= 0) {
                int events = 0;
@@ -221,6 +225,8 @@ int Looper::pollInner(int timeoutMillis) {
            }
        }
    }
    if (acquiredLock) {
        mLock.unlock();
    }

    for (size_t i = 0; i < mResponses.size(); i++) {