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

Commit 7fa048f2 authored by Jeff Brown's avatar Jeff Brown Committed by Android Git Automerger
Browse files

am 7d4739be: Merge "Reduce lock thrashing in native Looper." into gingerbread

Merge commit '7d4739bed5cd5f41ddfa431446b51f61b94d7b0b' into gingerbread-plus-aosp

* commit '7d4739bed5cd5f41ddfa431446b51f61b94d7b0b':
  Reduce lock thrashing in native Looper.
parents a6e7b5f5 13968742
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++) {