Re: Making Event work for Win32
[email protected] (Nick Ing-Simmons)
| Newsgroups | perl.loop |
|---|---|
| Organization | via, but not speaking for : Texas Instruments Ltd. |
| Message-ID | <[email protected]> |
Graham Barr <[email protected]> writes: > >Ak, Event does rely on there being one place where all events can be waited upon, >with the exception of signals as the will cause the poll to return anyway. Tcl (and hence perl/Tk as I steal it) does this by messing with the "timeout" value to select/poll/WaitForMultipleObjects while polling the non-selectable event types - that is: sub get_events { $timeout = 10mS; # say foreach $source (@awkward_sources) { $timeout = 0 if ($source->queue_events); # } select_or_poll_etc(@other_sources,$timeout); foreach $source (@other_sources) { $source->queue_events; } } sub do_one_event { my $wait = shift; while (1) { if (@queue) { my $event = shift(@queue); $event->process; return 1; } get_events(); last unless $wait; } return 0; } The n-stage process makes it necessary to have a queue of events or you need to re-enter the "get_events" thing at the appropriate point - skipping the ones which have had their turn - to be "fair". -- Nick Ing-Simmons <[email protected]> Via, but not speaking for: Texas Instruments Ltd.