On 31.03.2009, at 09:28, MacArthur, Ian (SELEX GALILEO, UK) wrote:
> Most of the time, I call awake with no parameters, it just serves to
> tell the main thread that something has been changed in the child
> thread
> and needs redrawn.
"awake" without parameters is great for - well - simply waking up the
application. It does not really matter, how many times "awake" is
called. The GUI will simply be kicked into gear again at the next
occasion.
I added the extended "awake" function by popular request. It is a nice
way to have a deferred callback which can do all the GUI calls needed
without ever using any locks or unlocks. The extended version of awake
is basically a full message queue system. The disadvantage here is,
that the number of calls are limited by space and cost.
So, a typical exampe for awake() would be:
someThread() {
for (i=0; i<1000000; i++) {
callSomeSlowCalculation(i);
updateProgressbar(i);
Fl::awake(); // make the rendering of the progressbar visible
}
}
A typical example for awake(cb, data) would be:
someThread() {
socket *s;
for (;;) {
select(s);
if (s->dataAvailable()) {
Fl::awake(blinkActivityLight, s);
}
}
}
blinkActivityLight() {
static bool on = true;
if (on)
activityLight->color(FL_RED);
else
activityLight->color(FL_GREEN);
on = ~on;
}
----
http://robowerk.com/
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk