laziness, impatience, and hubris | |
PerlMonks |
Re: Responsive GUI without threadsby jbert (Priest) |
on Oct 25, 2006 at 12:07 UTC ( [id://580555]=note: print w/replies, xml ) | Need Help?? |
To do this sort of thing in one process, as a general rule, you have to avoid operations which block or more generally, which take a long time.
This means doing things like using async I/O, breaking long computations into chunks which can be called on a 'tick' basis etc. This can be a pain (as can servicing more than one event loop in a program). It is a different kind of pain than threading or fork+IPC. A 'normal' sequential program is essentially a list of "do A, do B, do C". It doesn't matter if doB takes a long time, you've got nothing else to do apart from doB anyway (since you don't have to doC until doB is done). The problem comes when your program wants to respond to things (user input, network connections etc). Because now it has (at least) two jobs to do concurrently - "listen for new events" and "handle event". You can then:
In Section
Seekers of Perl Wisdom
|
|