Sujet : Re: Event loop and http::geturl
De : ralfixx (at) *nospam* gmx.de (Ralf Fassel)
Groupes : comp.lang.tclDate : 27. Jun 2025, 17:18:32
Autres entêtes
Message-ID : <ygav7ohyx7r.fsf@akutech.de>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
* Christian Gollwitzer <
auriocus@gmx.de>
| Am 26.06.25 um 23:02 schrieb et99:
| > I wonder, if you are reading a file that is being written from
| > another process, sort of like a "tail" program, doesn't tcl's
| > [fileevent
| > <channel> readable <script>] trigger constantly? Isn't this in
| > effect a tight polling loop?
>
| The underlying mechanism is select() or poll(). To my knowledge, this
| only works for pipes/sockets, not for files.
select() also works for files, the effect is that it indeed triggers
immediately on each call.
man select(2)
[...]
readfds
The file descriptors in this set are watched to see if they are
ready for reading.
** A file descriptor is ready for reading if a read operation will not block;
in particular, a file descriptor is also ready on end-of-file.
(** emphasis by me).
The effect in TCL of setting a readable-fileevent on a regular disk file
is indeed that the event fires repeatedly until EOF, blocking any GUI
updates which would run "after idle".
R'