On 8 October 2010 15:57, Andrew Brunner wrote: > A better way of achieving this is looking at the collection of threads > you have. Set your own booleans for Finished or if they > freeonterminate you will need to create an > TCompletes=Array[0..threadcount] of boolean. And as the threads free > set the variable of TCompletes to true. Then you can poll the > Completes to see if they are all true.
That comes down to the same thing I have done with the single boolean variable. All logging thread classes descend from a base log thread class. It's in that base thread class that I implemented the boolean variable. > There are a million ways to accomplish safe thread usage without waitfor... Yes, but my point is that FPC's "single source, compile everywhere" doesn't works so well in this case, because TThread.WaitFor works completely different under Windows to what it currently does under Unix/Linux. So the code now has to contain IFDEF's - which all tiOPF team members hate. Here is the offending bit of code in tiOPF's tiLog unit. procedure TtiLogToCacheAbs.Terminate; begin FThrdLog.Terminate; {$IFDEF FPC} { graemeg: 2009-05-04 FPC handles WaitFor slightly different under Unix environments, so I rather do the following which seems safer. Delphi could probably also use this method. When FThrdLog's Execute() method is done, it will set Finished to True, which we can then detect to know that the thread is done. See the following URL for a more detailed explanation: http://free-pascal-general.1045716.n5.nabble.com/TThread-WaitFor-not-returning-td2820297.html } while not FThrdLog.Finished do sleep(100); {$ELSE} FThrdLog.WaitFor; {$ENDIF} end; TtiLogToCacheAbs hold the cached log events, and feeds them to the thread which does the actual logging (to file, to screen, to OS system events, to debug server, etc) tiOPF code must run under D7-Delphi XE, and under latest stable FPC. So I'm limited to common features, and trying to reduce IFDEF's as much as possible. -- Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net:8080/fpgui/ _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal