GnuCash Daily Source Diff

Linas Vepstas linas@linas.org
Fri, 5 Oct 2001 12:59:26 -0500


On Fri, Oct 05, 2001 at 12:48:54PM -0400, Derek Atkins was heard to remark:
> PS: I do believe it is possible to create a client-server application
> purely using events, but you have to design that into the system from
> the ground up.

Yes you can, its the exception that proves the rule: its 'old-fashioned': 
the original Mac OS, the internals of the X server.  In the x server,
you listen to all these sockets (MacOS: application is 'event driven',
does nothing till it gets an event). When something comes in (an X11
drawing command, a MacOS event), you decode it (what command or 'event'
was it?) and you dispatch it: you call some routine that does something
with this particular command/event.  It runs till done, and it returns 
to the dispatcher, which sends out the next drawing command/ MacOS event.
Works great as long as you can draw everything quickly/your App doesn't
need lots of cpu time.  As soon as one of them becomes a cpu hog (e.g.
an OpenGL textured triangle, or some MacOS big document print), then all
the other events get 'starved' for cpu time. You loose responsiveness
(MacOS gets sluggish/stalls, Xserver appears to freeze up for a
fractional second).  So then, you invent ways of breaking up the big 
task into little tasks.  You stop in the middle of the big one to see 
if there are other pending requests.  Maybe you use signals/interrupts 
for this.  Maybe you start using setjmp()/longjmp()... you start thinking 
about 'fairness' and 'scheduling'... suddenly the words 'pre-emptive 
multitasking' start making sense ... viola, you've just reinvented 
threads, badly. 

Note how GUI apps are event-driven, and how <snipe>'serious' 
Java GUI programers like to use threads.  I don't think that means that 
Java programmers are smart: I think it means that Java GUI apps 
are slow and have responsiveness problems...</snipe>

--linas

-- 
pub  1024D/01045933 2001-02-01 Linas Vepstas (Labas!) <linas@linas.org>
     Key fingerprint = 8305 2521 6000 0B5E 8984  3F54 64A9 9A82 0104 5933