Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

PThread::PThread ( PINDEX  stackSize,
AutoDeleteFlag  deletion = AutoDeleteThread,
Priority  priorityLevel = NormalPriority,
const PString threadName = PString::Empty() 

Create a new thread instance. Unless the startSuspended# parameter is TRUE, the threads Main()# function is called to execute the code for the thread.

Note that the exact timing of the execution of code in threads can never be predicted. Thus you you can get a race condition on intialising a descendent class. To avoid this problem a thread is always started suspended. You must call the Resume() function after your descendent class construction is complete.

If synchronisation is required between threads then the use of semaphores is essential.

If the deletion# is set to AutoDeleteThread# then the PThread is assumed to be allocated with the new operator and may be freed using the delete operator as soon as the thread is terminated or executes to completion (usually the latter).

The stack size argument retained only for source code compatibility for previous implementations. It is not used in the current code and may be removed in subsequent versions.

stackSizeNot used - previously stack size
deletionAutomatically delete PThread instance on termination of thread.
priorityLevelInitial priority of thread.
threadNameThe name of the thread (for Debug/Trace)

Definition at line 1252 of file win32.cxx.

References AutoDeleteThread, Current(), PThread(), and SetPriority().

Referenced by PThread().

  : threadName(name)
  PAssert(stackSize > 0, PInvalidParameter);
  originalStackSize = stackSize;

  autoDelete = deletion == AutoDeleteThread;

#ifndef _WIN32_WCE
  threadHandle = (HANDLE)_beginthreadex(NULL, stackSize, MainFunction,
                                        this, CREATE_SUSPENDED, &threadId);
   threadHandle = CreateThread(NULL, stackSize, 
                               this, CREATE_SUSPENDED, (LPDWORD) &threadId);

  PAssertOS(threadHandle != NULL);


  traceBlockIndentLevel = 0;

  if (autoDelete) {
    PProcess & process = PProcess::Current();

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index