diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-09-13 23:17:30 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2010-09-14 01:59:45 -0700 |
commit | 4fe6c3e51be77e35f40872cdbca6c80f8f8b7ecb (patch) | |
tree | 5cbcfad147ad1bf26deb384e41d27f4e6bfcdb80 /core/jni/android_os_MessageQueue.cpp | |
parent | c891d2b3529b9cf24ef4781a585cd4784815e711 (diff) | |
download | frameworks_base-4fe6c3e51be77e35f40872cdbca6c80f8f8b7ecb.zip frameworks_base-4fe6c3e51be77e35f40872cdbca6c80f8f8b7ecb.tar.gz frameworks_base-4fe6c3e51be77e35f40872cdbca6c80f8f8b7ecb.tar.bz2 |
Replace epoll() with poll() and rename PollLoop to Looper.
As part of this change, consolidated and cleaned up the Looper API so
that there are fewer distinctions between the NDK and non-NDK declarations
(no need for two callback types, etc.).
Removed the dependence on specific constants from sys/poll.h such as
POLLIN. Instead looper.h defines events like LOOPER_EVENT_INPUT for
the events that it supports. That should help make any future
under-the-hood implementation changes easier.
Fixed a couple of compiler warnings along the way.
Change-Id: I449a7ec780bf061bdd325452f823673e2b39b6ae
Diffstat (limited to 'core/jni/android_os_MessageQueue.cpp')
-rw-r--r-- | core/jni/android_os_MessageQueue.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/core/jni/android_os_MessageQueue.cpp b/core/jni/android_os_MessageQueue.cpp index 847b5a5..1b203ca 100644 --- a/core/jni/android_os_MessageQueue.cpp +++ b/core/jni/android_os_MessageQueue.cpp @@ -18,7 +18,7 @@ #include "JNIHelp.h" -#include <utils/PollLoop.h> +#include <utils/Looper.h> #include <utils/Log.h> #include "android_os_MessageQueue.h" @@ -39,22 +39,22 @@ public: NativeMessageQueue(); ~NativeMessageQueue(); - inline sp<PollLoop> getPollLoop() { return mPollLoop; } + inline sp<Looper> getLooper() { return mLooper; } bool pollOnce(int timeoutMillis); void wake(); private: - sp<PollLoop> mPollLoop; + sp<Looper> mLooper; }; // ---------------------------------------------------------------------------- NativeMessageQueue::NativeMessageQueue() { - mPollLoop = PollLoop::getForThread(); - if (mPollLoop == NULL) { - mPollLoop = new PollLoop(false); - PollLoop::setForThread(mPollLoop); + mLooper = Looper::getForThread(); + if (mLooper == NULL) { + mLooper = new Looper(false); + Looper::setForThread(mLooper); } } @@ -62,11 +62,11 @@ NativeMessageQueue::~NativeMessageQueue() { } bool NativeMessageQueue::pollOnce(int timeoutMillis) { - return mPollLoop->pollOnce(timeoutMillis) != PollLoop::POLL_TIMEOUT; + return mLooper->pollOnce(timeoutMillis) != ALOOPER_POLL_TIMEOUT; } void NativeMessageQueue::wake() { - mPollLoop->wake(); + mLooper->wake(); } // ---------------------------------------------------------------------------- @@ -83,10 +83,10 @@ static void android_os_MessageQueue_setNativeMessageQueue(JNIEnv* env, jobject m reinterpret_cast<jint>(nativeMessageQueue)); } -sp<PollLoop> android_os_MessageQueue_getPollLoop(JNIEnv* env, jobject messageQueueObj) { +sp<Looper> android_os_MessageQueue_getLooper(JNIEnv* env, jobject messageQueueObj) { NativeMessageQueue* nativeMessageQueue = android_os_MessageQueue_getNativeMessageQueue(env, messageQueueObj); - return nativeMessageQueue != NULL ? nativeMessageQueue->getPollLoop() : NULL; + return nativeMessageQueue != NULL ? nativeMessageQueue->getLooper() : NULL; } static void android_os_MessageQueue_nativeInit(JNIEnv* env, jobject obj) { |