At Thu, 7 Jun 2018 20:13:47 -0000 (UTC) Rich <ri...@example.invalid> wrote:
>
> Cecil Westerhof <
Ce...@decebal.nl> wrote:
> > Rich <ri...@example.invalid> writes:
> >
> >> Cecil Westerhof <
Ce...@decebal.nl> wrote:
> >>> I often want an event loop that runs forever and terminates when there
> >>> is an error. for this I created the proc startEventLoop.
> >>>
> >>> You can find it here:
> >>>
http://wiki.tcl.tk/55367
> >>
> >> One small tip, if you perchance ever wanted to exit the event loop (by
> >> exiting the vwait due to setting the variable) then you might consider
> >> making the "forever" variable inside the proc a global.
> >>
> >> As it is a local now, there is no way to set it (because it is proc
> >> local) after you do get into the event loop.
> >
> > Well, the idea is that it runs forever. ;-)
>
> Normally, yes. But then, one day, you end up needing to do something
> after exiting the event loop cleanly.....
Normally, all you will ever do after exiting the event loop is exit. If you
need to do something else just before exiting, you could just include that in
the exit code:
proc myCleanExit {} {
# clean things up (close files, close sockets, delete temp files, whatever)
::exit
}
Then in your code (somewhere deep under the event loop possibly) you call
myCleanExit.
>
> > But I could at a parameter that while the default is False would make
> > the variable global when the parameter is True.
>
> Other than hiding the variable there is no performance difference,
> since there are at most two accesses to the variable during the whole
> runtime (the vwait setup, and a 'set' at some point when a clean exit
> is desired (if it is ever desired...).
>
--
Robert Heller --
978-544-6933
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
hel...@deepsoft.com -- Webhosting Services