[fpc-pascal] Where is IsMultiThreaded set under Linux?

Andrew Brunner andrew.t.brunner at gmail.com
Fri Oct 8 15:57:36 CEST 2010


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.

There are a million ways to accomplish safe thread usage without waitfor...


On Fri, Oct 8, 2010 at 8:49 AM, Graeme Geldenhuys
<graemeg.lists at gmail.com> wrote:
> On 8 October 2010 15:32, Andrew Brunner wrote:
>> This seems like a discussion of semantics more than anything.  In an
>> application thread if you say WAITFOR something then the app cannot
>> process messages b/c the execution is put on hold until WAITFOR
>> returns.  This is normal behaviour, IMO.
>>
>> So if this is just an exercise, I really don't see a problem.  What's
>> the issue you're trying to solve?
>
> OK, my example just just that... to highlight the problem of using
> TThread.WaitFor.
>
> My real usage is in tiOPF. tiOPF has various cached logging classes,
> all done via threads. It's cached
> because we don't want to slow down the main application while output
> is written to a file or log window. So logging is written out to disk (or
> a GUI screen) when the thread gets time slices.  Now say you instantly
> generated 1 million log entries (so the thread has a huge backlog, and
> because you have a slow hard drive...in the case of logging to a
> file), and now you quit your application.
> The application needs to wait for the logging threads to complete
> before it can terminate.
> This is where the problem comes in. As soon as I call
> SomeThread.WaitFor, the application is frozen - it never gets to
> terminate completely because WaitFor never returns. All our apps are
> database GUI apps, but strangely enough, it is not only limited to GUI
> apps. The unit testing framework of tiOPF is Text or GUI. I run the
> daily build under our Linux server and it is non-gui based. The test
> runs never complete/terminate because there are five logging threads
> frozen which never returned from WaitFor. So I had to implement that
> boolean field and a while loop hack, instead of calling WaitFor [when
> I use FPC and Linux].
>
>
> --
> Regards,
>   - Graeme -
>
>
> _______________________________________________
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://opensoft.homeip.net:8080/fpgui/
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



More information about the fpc-pascal mailing list