Merge "fix an issue where updates could starve transactions"
This commit is contained in:
commit
1d04d872b4
@ -44,8 +44,7 @@ void MessageBase::handleMessage(const Message&) {
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
MessageQueue::MessageQueue()
|
MessageQueue::MessageQueue()
|
||||||
: mLooper(new Looper(true)),
|
: mLooper(new Looper(true))
|
||||||
mInvalidatePending(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,17 +53,13 @@ MessageQueue::~MessageQueue() {
|
|||||||
|
|
||||||
void MessageQueue::waitMessage() {
|
void MessageQueue::waitMessage() {
|
||||||
do {
|
do {
|
||||||
// handle invalidate events first
|
|
||||||
if (android_atomic_and(0, &mInvalidatePending) != 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
IPCThreadState::self()->flushCommands();
|
IPCThreadState::self()->flushCommands();
|
||||||
|
|
||||||
int32_t ret = mLooper->pollOnce(-1);
|
int32_t ret = mLooper->pollOnce(-1);
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case ALOOPER_POLL_WAKE:
|
case ALOOPER_POLL_WAKE:
|
||||||
// we got woken-up there is work to do in the main loop
|
// we got woken-up there is work to do in the main loop
|
||||||
continue;
|
return;
|
||||||
|
|
||||||
case ALOOPER_POLL_CALLBACK:
|
case ALOOPER_POLL_CALLBACK:
|
||||||
// callback was handled, loop again
|
// callback was handled, loop again
|
||||||
@ -99,7 +94,6 @@ status_t MessageQueue::postMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
status_t MessageQueue::invalidate() {
|
status_t MessageQueue::invalidate() {
|
||||||
android_atomic_or(1, &mInvalidatePending);
|
|
||||||
mLooper->wake();
|
mLooper->wake();
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,6 @@ private:
|
|||||||
|
|
||||||
class MessageQueue {
|
class MessageQueue {
|
||||||
sp<Looper> mLooper;
|
sp<Looper> mLooper;
|
||||||
volatile int32_t mInvalidatePending;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MessageQueue();
|
MessageQueue();
|
||||||
|
Loading…
Reference in New Issue
Block a user