[fpc-devel] Threads and alot of crap continued
almindor at gmail.com
Tue Nov 7 17:10:34 CET 2006
> Of course, because the common concept of a timer is as asynchronous as
> in "multi-threaded" or even "interrupt".
> You're not seriously trying to work around that simple fact, do you?
Actualy I am, because lNet is single-threaded non-blocking.
As for general use, you can't do a Timer this way. You can't just put a
TTimer in which works in it's own thread and then calls some callback in
it's own thread, unless the users are informed, and-or the thing is
locked and protected but you can't do that from within a TThread
(because you don't know what the callback code is).
Basicly a solution might be a thread which CriticalSections the callback
part, but that still doesn't protect from wrong stuff: eg the user is in
a loop and the code inside the OnTimer callback modifies something which
breaks or loopies the loop.
In case of gui TTimer this cannot happen because it's not threaded, so
the userloop would first finish, then the user function returns and the
main gui loop does it's stuff (this is my oh-so-complicated part, done
by the gui).
> fpc-devel maillist - fpc-devel at lists.freepascal.org
More information about the fpc-devel