On Mon, 12 Jul 2010, Jonas Maebe wrote:
Alexander Grau wrote on Mon, 12 Jul 2010:
Am 12.07.2010 um 22:31 schrieb Jonas Maebe:
I forgot to mention: before this works, you have to create at least one
thread using the FPC RTL in order to initialise the threading subsystem.
It can be terminated/freed immediately, see the test program that was
committed together with the fix for an example.
That did the trick! Seems to work - I'm really curious how this works,
since I assume there's probably no control over how the external C thread
is created and so no chance to initialize something for the FPC runtime ...
The FPC runtime support for such a thread is initialised the first time you
access a threadvar from that thread. And there's also a way to make
libpthread automatically call a "destructor" routine when such a thread
finishes (that's what I discovered today, and which was the missing piece of
the puzzle).
Jonas, if only I had known these 2 little details 5 years ago, when I needed
it for Apache module support :/
Thank you very much. This is a great step forward !!
One small detail : maybe we should create a call 'inittheading' or make the
'IsMultithreaded' variable a property, that, when written, does the
initialization ?
That's a bit cleaner than creating a thread ?
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal