Initializing threading

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Initializing threading

Andreas Berger
In order to initialize threading under DOS I must create a separate unit
since I need the initialization and finalization clause. I thought of
using a cthreads.pp unit like in unix. However, the TThread
implementation resides in the TThread.inc file which is an include in
the implementation section of the system.pp unit which is always loaded.
This causes the following problem: If someone creates a TThread, the
constructor does not know if threading has been initialized (via
cthreads) since I can not add a "uses cthreads" clause in the .inc file.

Does anyone have any idea how I can resolve this?

regards,
Andreas

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Initializing threading

Vinzent Höfler
On Tuesday 25 July 2006 14:18, Andreas Berger wrote:

> In order to initialize threading under DOS I must create a separate
> unit since I need the initialization and finalization clause. I
> thought of using a cthreads.pp unit like in unix. However, the
> TThread
> implementation resides in the TThread.inc file which is an include in
> the implementation section of the system.pp unit which is always
> loaded.

AFAIR the TThread implementation makes use of the ThreadManager (it
calls BeginThread and all that stuff).

> This causes the following problem: If someone creates a
> TThread, the constructor does not know if threading has been
> initialized (via cthreads) since I can not add a "uses cthreads"
> clause in the .inc file.
>
> Does anyone have any idea how I can resolve this?

Initialize is it in the BeginThread subroutine of your ThreadManager as
it is done for all other targets that need special initialization.
There is a global variable System.IsMultThread for exactly that
purpose, I think.


Vinzent.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Initializing threading

Michael Van Canneyt
In reply to this post by Andreas Berger


On Tue, 25 Jul 2006, Andreas Berger wrote:

> In order to initialize threading under DOS I must create a separate unit
> since I need the initialization and finalization clause. I thought of using a
> cthreads.pp unit like in unix. However, the TThread implementation resides in
> the TThread.inc file which is an include in the implementation section of the
> system.pp unit which is always loaded.

This is not correct. TThread is in the classes unit.

> This causes the following problem: If
> someone creates a TThread, the constructor does not know if threading has
> been initialized (via cthreads) since I can not add a "uses cthreads" clause
> in the .inc file.
>
> Does anyone have any idea how I can resolve this?

You don't need to resolve this. The application will stop with an error
if you forget to add cthreads and try to start a thread.

There is nothing else it can do.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal