Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-07

Initializing threading

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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

Reply by email

Vinzent Hoefler
to Andreas Berger
Andreas Berger wrote 7 lines
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).

Show quoted text 6 lines
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.

Reply by email

Michael Van Canneyt
to Andreas Berger: In order to initialize threading under DOS I must create a separate unit since I need the…
Andreas Berger wrote 5 lines
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.

Show quoted text 6 lines
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.

Reply by email