What is the point of postMessage() etc on android?


#1

What I see is that a postMessage() just invokes the messagecallback which happens a bit later.

I can't see anywhere that the Android code uses it... what am I missing?


#2

Don't understand the question.. The point of that method is the same on android as it is on all the other OSes... It's used internally by loads of the other classes, e.g. Timers, AsyncUpdaters, etc etc


#3

OK.  But since it has to percolate over the JNI up to the Java and then around through a roundabout mechanism before getting sent back down to the C++ level, it seems like a waste of CPU.  Is there a specific reason for the round trip, or could it be just as easily accomplished using an internal thread+queue in the C++?


#4

No.. it's essential that it happens on the system message thread, alongside the other GUI messages on the event loop.

Besides, the amount of CPU involved should be tiny. You shouldn't fall into the trap of worrying about CPU except for functions that you've actually profiled and measured to be a problem.


#5

Hi, Jules -

No, I'm not an excessive profiler fanatic.  But it just seemed odd.  Now you've explained it, it's less odd :)