thread.h
Go to the documentation of this file.
/*
* thread.h
*
* Executable thread encapsulation class (pre-emptive if OS allows).
*
* Portable Tools Library
*
* Copyright (c) 1993-1998 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Portions are Copyright (C) 1993 Free Software Foundation, Inc.
* All Rights Reserved.
*
* Contributor(s): ______________________________________.
*
* $Revision: 28050 $
* $Author: rjongbloed $
* $Date: 2012-07-18 02:15:30 -0500 (Wed, 18 Jul 2012) $
*/
#ifndef PTLIB_THREAD_H
#define PTLIB_THREAD_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#ifdef Priority
#undef Priority
#endif
#include <ptlib/mutex.h>
class PSemaphore;
// PThread
class PThread : public PObject
{
PCLASSINFO(PThread, PObject);
public:
enum Priority {
LowestPriority,
LowPriority,
NormalPriority,
HighPriority,
HighestPriority,
NumPriorities
};
enum AutoDeleteFlag {
AutoDeleteThread,
NoAutoDeleteThread
};
PThread(
PINDEX,
AutoDeleteFlag deletion = AutoDeleteThread,
Priority priorityLevel = NormalPriority,
const PString & threadName = PString::Empty()
);
~PThread();
void PrintOn(
ostream & strm
) const;
virtual void Restart();
virtual void Terminate();
virtual PBoolean IsTerminated() const;
void WaitForTermination() const;
PBoolean WaitForTermination(
const PTimeInterval & maxWait
) const;
virtual void Suspend(
PBoolean susp = true
);
virtual void Resume();
virtual PBoolean IsSuspended() const;
static void Sleep(
const PTimeInterval & delay
);
virtual void SetPriority(
Priority priorityLevel
);
virtual Priority GetPriority() const;
virtual void SetAutoDelete(
AutoDeleteFlag deletion = AutoDeleteThread
);
void SetNoAutoDelete() { SetAutoDelete(NoAutoDeleteThread); }
virtual PString GetThreadName() const;
virtual void SetThreadName(
const PString & name
);
virtual PThreadIdentifier GetThreadId() const { return m_threadId; }
static PThreadIdentifier GetCurrentThreadId();
struct Times
{
PTimeInterval m_real;
PTimeInterval m_kernel;
PTimeInterval m_user;
friend ostream & operator<<(ostream & strm, const Times & times);
};
bool GetTimes(
Times & times
);
virtual void Main() = 0;
static PThread * Current();
static void Yield();
static PThread * Create(
const PNotifier & notifier,
INT parameter = 0,
AutoDeleteFlag deletion = AutoDeleteThread,
Priority priorityLevel = NormalPriority,
const PString & threadName = PString::Empty(),
PINDEX stackSize = 65536
);
static PThread * Create(
const PNotifier & notifier,
const PString & threadName
) { return Create(notifier, 0, NoAutoDeleteThread, NormalPriority, threadName); }
bool IsAutoDelete() const { return m_autoDelete; }
private:
PThread(bool isProcess);
// Create a new thread instance as part of a <code>PProcess</code> class.
friend class PProcess;
friend class PExternalThread;
friend class PHouseKeepingThread;
// So a PProcess can get at PThread() constructor but nothing else.
PThread(const PThread &) : PObject () { }
// Empty constructor to prevent copying of thread instances.
PThread & operator=(const PThread &) { return *this; }
// Empty assignment operator to prevent copying of thread instances.
protected:
bool m_isProcess;
bool m_autoDelete; // Automatically delete the thread on completion.
PINDEX m_originalStackSize;
PString m_threadName; // Give the thread a name for debugging purposes.
PMutex m_threadNameMutex;
PThreadIdentifier m_threadId;
#if PTRACING
public:
struct TraceInfo {
TraceInfo()
{ traceBlockIndentLevel = 0; }
PStack<PStringStream> traceStreams;
unsigned traceLevel;
unsigned traceBlockIndentLevel;
};
#ifndef P_HAS_THREADLOCAL_STORAGE
private:
friend class PTrace;
TraceInfo traceInfo;
#endif // P_HAS_THREADLOCAL_STORAGE
#endif // PTRACING
// Include platform dependent part of class
#ifdef _WIN32
#include "msos/ptlib/thread.h"
#else
#include "unix/ptlib/thread.h"
#endif
};
// Include definition of platform dependent thread ID format
#if defined(_WIN32) && !defined(_WIN32_WCE)
#define PTHREAD_ID_FMT "%u"
#else
#define PTHREAD_ID_FMT "0x%lx"
#endif
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
/*
This class automates calling a global function with no arguments within it's own thread.
It is used as follows:
void GlobalFunction()
{
}
...
PString arg;
new PThreadMain(&GlobalFunction)
*/
class PThreadMain : public PThread
{
PCLASSINFO(PThreadMain, PThread);
public:
typedef void (*FnType)();
PThreadMain(FnType function, bool autoDel = false)
: PThread(10000, autoDel ? PThread::AutoDeleteThread : PThread::NoAutoDeleteThread)
, m_function(function)
{ PThread::Resume(); }
PThreadMain(const char * file, int line, FnType function, bool autoDel = false)
: PThread(10000, autoDel ? PThread::AutoDeleteThread : PThread::NoAutoDeleteThread, NormalPriority,
psprintf("%s:%08x-%s:%i", GetClass(), (void *)this, file, line))
, m_function(function)
{ PThread::Resume(); }
virtual void Main()
{ (*m_function)(); }
protected:
FnType m_function;
};
/*
This template automates calling a global function with one argument within it's own thread.
It is used as follows:
void GlobalFunction(PString arg)
{
}
...
PString arg;
new PThread1Arg<PString>(arg, &GlobalFunction)
*/
template<typename Arg1Type>
class PThread1Arg : public PThread
{
PCLASSINFO(PThread1Arg, PThread);
public:
typedef void (*FnType)(Arg1Type arg1);
PThread1Arg(Arg1Type arg1, FnType function, bool autoDel = false)
: PThread(10000, autoDel ? PThread::AutoDeleteThread : PThread::NoAutoDeleteThread)
, m_function(function)
, m_arg1(arg1)
{ PThread::Resume(); }
PThread1Arg(const char * file, int line, Arg1Type arg1, FnType function, bool autoDel = false)
: PThread(10000, autoDel ? PThread::AutoDeleteThread : PThread::NoAutoDeleteThread, NormalPriority,
psprintf("%s:%08x-%s:%i", GetClass(), (void *)this, file, line))
, m_function(function)
, m_arg1(arg1)
{ PThread::Resume(); }
virtual void Main()
{ (*m_function)(m_arg1); }
protected:
FnType m_function;
Arg1Type m_arg1;
};
/*
This template automates calling a global function with two arguments within it's own thread.
It is used as follows:
void GlobalFunction(PString arg1, int arg2)
{
}
...
PString arg;
new PThread2Arg<PString, int>(arg1, arg2, &GlobalFunction)
*/
template<typename Arg1Type, typename Arg2Type>
class PThread2Arg : public PThread
{
PCLASSINFO(PThread2Arg, PThread);
public:
typedef void (*FnType)(Arg1Type arg1, Arg2Type arg2);
PThread2Arg(Arg1Type arg1, Arg2Type arg2, FnType function, bool autoDel = false)
: PThread(10000, autoDel ? PThread::AutoDeleteThread : PThread::NoAutoDeleteThread)
, m_function(function)
, m_arg1(arg1)
, m_arg2(arg2)
{ PThread::Resume(); }
PThread2Arg(const char * file, int line, Arg1Type arg1, Arg2Type arg2, FnType function, bool autoDel = false)
: PThread(10000, autoDel ? PThread::AutoDeleteThread : PThread::NoAutoDeleteThread, NormalPriority,
psprintf("%s:%08x-%s:%i", GetClass(), (void *)this, file, line))
, m_function(function)
, m_arg1(arg1)
, m_arg2(arg2)
{ PThread::Resume(); }
virtual void Main()
{ (*m_function)(m_arg1, m_arg2); }
protected:
FnType m_function;
Arg1Type m_arg1;
Arg2Type m_arg2;
};
/*
This template automates calling a global function with three arguments within it's own thread.
It is used as follows:
void GlobalFunction(PString arg1, int arg2, int arg3)
{
}
...
PString arg;
new PThread3Arg<PString, int, int>(arg1, arg2, arg3, &GlobalFunction)
*/
template<typename Arg1Type, typename Arg2Type, typename Arg3Type>
class PThread3Arg : public PThread
{
PCLASSINFO(PThread3Arg, PThread);
public:
typedef void (*FnType)(Arg1Type arg1, Arg2Type arg2, Arg3Type arg3);
PThread3Arg(Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, FnType function, bool autoDel = false)
: PThread(10000, autoDel ? PThread::AutoDeleteThread : PThread::NoAutoDeleteThread)
, m_function(function)
, m_arg1(arg1)
, m_arg2(arg2)
, m_arg3(arg3)
{ PThread::Resume(); }
PThread3Arg(const char * file, int line, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, FnType function, bool autoDel = false)
: PThread(10000, autoDel ? PThread::AutoDeleteThread : PThread::NoAutoDeleteThread, NormalPriority,
psprintf("%s:%08x-%s:%i", GetClass(), (void *)this, file, line))
, m_function(function)
, m_arg1(arg1)
, m_arg2(arg2)
, m_arg3(arg3)
{ PThread::Resume(); }
virtual void Main()
{ (*m_function)(m_arg1, m_arg2, m_arg3); }
protected:
FnType m_function;
Arg1Type m_arg1;
Arg2Type m_arg2;
Arg2Type m_arg3;
};
/*
This template automates calling a member function with no arguments within it's own thread.
It is used as follows:
class Example {
public:
void Function()
{
}
};
...
Example ex;
new PThreadObj<Example>(ex, &Example::Function)
*/
template <typename ObjType>
class PThreadObj : public PThread
{
PCLASSINFO(PThreadObj, PThread);
public:
typedef void (ObjType::*ObjTypeFn)();
PThreadObj(
ObjType & obj,
ObjTypeFn function,
bool autoDel = false,
const char * name = NULL,
PThread::Priority priority = PThread::NormalPriority
) : PThread(10000,
autoDel ? PThread::AutoDeleteThread : PThread::NoAutoDeleteThread,
priority,
name)
, m_object(obj)
, m_function(function)
{
PThread::Resume();
}
void Main()
{
(m_object.*m_function)();
}
protected:
ObjType & m_object;
ObjTypeFn m_function;
};
/*
This template automates calling a member function with one argument within it's own thread.
It is used as follows:
class Example {
public:
void Function(PString arg)
{
}
};
...
Example ex;
PString str;
new PThreadObj1Arg<Example>(ex, str, &Example::Function)
*/
template <class ObjType, typename Arg1Type>
class PThreadObj1Arg : public PThread
{
PCLASSINFO(PThreadObj1Arg, PThread);
public:
typedef void (ObjType::*ObjTypeFn)(Arg1Type);
PThreadObj1Arg(
ObjType & obj,
Arg1Type arg1,
ObjTypeFn function,
bool autoDel = false,
const char * name = NULL,
PThread::Priority priority = PThread::NormalPriority
) : PThread(10000,
autoDel ? PThread::AutoDeleteThread : PThread::NoAutoDeleteThread,
priority,
name)
, m_object(obj)
, m_function(function)
, m_arg1(arg1)
{
PThread::Resume();
}
void Main()
{
(m_object.*m_function)(m_arg1);
}
protected:
ObjType & m_object;
ObjTypeFn m_function;
Arg1Type m_arg1;
};
template <class ObjType, typename Arg1Type, typename Arg2Type>
class PThreadObj2Arg : public PThread
{
PCLASSINFO(PThreadObj2Arg, PThread);
public:
typedef void (ObjType::*ObjTypeFn)(Arg1Type, Arg2Type);
PThreadObj2Arg(
ObjType & obj,
Arg1Type arg1,
Arg2Type arg2,
ObjTypeFn function,
bool autoDel = false,
const char * name = NULL,
PThread::Priority priority = PThread::NormalPriority
) : PThread(10000,
autoDel ? PThread::AutoDeleteThread : PThread::NoAutoDeleteThread,
priority,
name)
, m_object(obj)
, m_function(function)
, m_arg1(arg1)
, m_arg2(arg2)
{
PThread::Resume();
}
void Main()
{
(m_object.*m_function)(m_arg1, m_arg2);
}
protected:
ObjType & m_object;
ObjTypeFn m_function;
Arg1Type m_arg1;
Arg2Type m_arg2;
};
//
// PThreadLocalStorage
//
#ifdef _WIN32
#define P_HAS_THREADLOCAL_STORAGE 1
template <class Storage_T>
class PThreadLocalStorage
{
public:
typedef DWORD Key_T;
typedef Storage_T value_type;
PThreadLocalStorage()
{ key = TlsAlloc(); }
~PThreadLocalStorage()
{ TlsFree(key); }
Key_T GetKey() const
{ return key; }
value_type * Get()
{ return (value_type *) TlsGetValue(key); }
void Set(value_type * v)
{ TlsSetValue(key, (LPVOID)v); }
protected:
DWORD key;
};
#elif defined(P_PTHREADS)
#include <pthread.h>
#define P_HAS_THREADLOCAL_STORAGE 1
template <class Storage_T>
class PThreadLocalStorage
{
public:
typedef pthread_key_t Key_T;
typedef Storage_T value_type;
PThreadLocalStorage()
{ pthread_key_create(&key, NULL); }
~PThreadLocalStorage()
{ pthread_key_delete(key); }
Key_T GetKey() const
{ return key; }
value_type * Get()
{ return (value_type *)pthread_getspecific(key); }
void Set(value_type * v)
{ pthread_setspecific(key, v); }
private:
Key_T key;
};
#else
#undef P_HAS_THREADLOCAL_STORAGE 1
#warning("Thread local storage not supported");
#endif
#ifdef _MSC_VER
#pragma warning(default:4355)
#endif
#endif // PTLIB_THREAD_H
// End Of File ///////////////////////////////////////////////////////////////
PThread::HighPriority
Runs approximately twice as often as normal.
Definition: thread.h:81
PThreadObj2Arg::m_arg2
Arg2Type m_arg2
Definition: thread.h:717
PThread::WaitForTermination
void WaitForTermination() const
Block and wait for the thread to terminate.
PThread::AutoDeleteFlag
AutoDeleteFlag
Codes for thread autodelete flag.
Definition: thread.h:89
PThread1Arg::PThread1Arg
PThread1Arg(Arg1Type arg1, FnType function, bool autoDel=false)
Definition: thread.h:476
PSemaphore
This class defines a thread synchronisation object.
Definition: semaphor.h:78
PThread::GetThreadName
virtual PString GetThreadName() const
Get the name of the thread.
PTrace
Class to encapsulate tracing functions.
Definition: object.h:292
PThread2Arg::m_arg1
Arg1Type m_arg1
Definition: thread.h:532
PThread::Times
Times for execution of the thread.
Definition: thread.h:295
PThread3Arg::m_function
FnType m_function
Definition: thread.h:573
PTimeInterval
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:55
PThread::LowestPriority
Will only run if all other threads are blocked.
Definition: thread.h:75
PThread::LowPriority
Runs approximately half as often as normal.
Definition: thread.h:77
PThread::IsTerminated
virtual PBoolean IsTerminated() const
Determine if the thread has been terminated or ran to completion.
PThreadMain::Main
virtual void Main()
User override function for the main execution routine of the thread.
Definition: thread.h:450
PNotifier
Class specialisation for PNotifierTemplate<INT>
PThreadObj2Arg::ObjTypeFn
void(ObjType::* ObjTypeFn)(Arg1Type, Arg2Type)
Definition: thread.h:686
PThread3Arg::PThread3Arg
PThread3Arg(Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, FnType function, bool autoDel=false)
Definition: thread.h:554
PThreadMain::FnType
void(* FnType)()
Definition: thread.h:440
PThread::Create
static PThread * Create(const PNotifier &notifier, const PString &threadName)
Definition: thread.h:350
PThreadObj2Arg::m_arg1
Arg1Type m_arg1
Definition: thread.h:716
PThread::~PThread
~PThread()
Destroy the thread, this simply calls the Terminate() function with all its restrictions and penaltie...
PThreadObj1Arg::ObjTypeFn
void(ObjType::* ObjTypeFn)(Arg1Type)
Definition: thread.h:650
PThread3Arg::m_arg3
Arg2Type m_arg3
Definition: thread.h:576
PThread2Arg::FnType
void(* FnType)(Arg1Type arg1, Arg2Type arg2)
Definition: thread.h:513
PThread::PHouseKeepingThread
friend class PHouseKeepingThread
Definition: thread.h:364
PThread3Arg::m_arg2
Arg2Type m_arg2
Definition: thread.h:575
PThreadObj2Arg
Definition: thread.h:682
PThread::Main
virtual void Main()=0
User override function for the main execution routine of the thread.
PThread1Arg::m_arg1
Arg1Type m_arg1
Definition: thread.h:492
PThreadObj1Arg::m_function
ObjTypeFn m_function
Definition: thread.h:677
PThread::Resume
virtual void Resume()
Resume thread execution, this is identical to Suspend(false).
PThreadObj1Arg
Definition: thread.h:646
PThread2Arg::m_function
FnType m_function
Definition: thread.h:531
PThreadMain::PThreadMain
PThreadMain(FnType function, bool autoDel=false)
Definition: thread.h:441
PThread::Suspend
virtual void Suspend(PBoolean susp=true)
Suspend or resume the thread.
PThread::HighestPriority
Is only thread that will run, unless blocked.
Definition: thread.h:83
PThread::Priority
Priority
Codes for thread priorities.
Definition: thread.h:74
PThreadMain
Define some templates to simplify the declaration of simple PThread descendants with one or two param...
Definition: thread.h:436
PThread::m_autoDelete
bool m_autoDelete
Definition: thread.h:375
PThreadMain::PThreadMain
PThreadMain(const char *file, int line, FnType function, bool autoDel=false)
Definition: thread.h:445
PThreadObj1Arg::m_arg1
Arg1Type m_arg1
Definition: thread.h:678
PThread::PrintOn
void PrintOn(ostream &strm) const
Standard stream print function.
PThread::Sleep
static void Sleep(const PTimeInterval &delay)
Suspend the current thread for the specified amount of time.
PThread1Arg::Main
virtual void Main()
User override function for the main execution routine of the thread.
Definition: thread.h:487
PThread::Terminate
virtual void Terminate()
Terminate the thread.
PProcess
This class represents an operating system process.
Definition: pprocess.h:227
PThread::m_threadName
PString m_threadName
Definition: thread.h:378
PBoolean
BOOL PBoolean
Definition: object.h:102
PThread::NumPriorities
Definition: thread.h:85
PThread::GetThreadId
virtual PThreadIdentifier GetThreadId() const
Get operating system specific thread identifier for this thread.
Definition: thread.h:291
PThreadObj::m_object
ObjType & m_object
Definition: thread.h:624
PObject::GetClass
virtual const char * GetClass(unsigned ancestor=0) const
Get the current dynamic type of the object instance.
Definition: object.h:1158
PThread1Arg::FnType
void(* FnType)(Arg1Type arg1)
Definition: thread.h:474
PThreadObj2Arg::m_object
ObjType & m_object
Definition: thread.h:714
PThread::SetAutoDelete
virtual void SetAutoDelete(AutoDeleteFlag deletion=AutoDeleteThread)
Set the flag indicating thread object is to be automatically deleted when the thread ends...
PThread::m_isProcess
bool m_isProcess
Definition: thread.h:374
PThreadObj::PThreadObj
PThreadObj(ObjType &obj, ObjTypeFn function, bool autoDel=false, const char *name=NULL, PThread::Priority priority=PThread::NormalPriority)
Definition: thread.h:602
PThread2Arg::PThread2Arg
PThread2Arg(const char *file, int line, Arg1Type arg1, Arg2Type arg2, FnType function, bool autoDel=false)
Definition: thread.h:520
PString
The character string class.
Definition: pstring.h:108
PThread::Yield
static void Yield()
Yield to another thread without blocking.
PThreadMain::m_function
FnType m_function
Definition: thread.h:454
PThread::Times::m_kernel
PTimeInterval m_kernel
Total kernel CPU time in milliseconds.
Definition: thread.h:298
PString::Empty
static PString Empty()
Return an empty string.
PThread::NoAutoDeleteThread
Don't delete thread as it may not be on heap.
Definition: thread.h:94
mutex.h
PThread3Arg::Main
virtual void Main()
User override function for the main execution routine of the thread.
Definition: thread.h:569
PThread3Arg::PThread3Arg
PThread3Arg(const char *file, int line, Arg1Type arg1, Arg2Type arg2, Arg3Type arg3, FnType function, bool autoDel=false)
Definition: thread.h:561
PThreadObj
Definition: thread.h:596
PThread::SetNoAutoDelete
void SetNoAutoDelete()
Reet the flag indicating thread object is to be automatically deleted when the thread ends...
Definition: thread.h:265
PThread
This class defines a thread of execution in the system.
Definition: thread.h:66
PThread2Arg
Definition: thread.h:509
PThread::Times::m_real
PTimeInterval m_real
Total real time since thread start in milliseconds.
Definition: thread.h:297
PThread2Arg::Main
virtual void Main()
User override function for the main execution routine of the thread.
Definition: thread.h:527
PThread::m_threadNameMutex
PMutex m_threadNameMutex
Definition: thread.h:379
PThread3Arg
Definition: thread.h:549
PThread2Arg::m_arg2
Arg2Type m_arg2
Definition: thread.h:533
PThread::GetTimes
bool GetTimes(Times &times)
Get the thread execution times.
PThread::GetCurrentThreadId
static PThreadIdentifier GetCurrentThreadId()
PThreadObj::Main
void Main()
User override function for the main execution routine of the thread.
Definition: thread.h:618
PThread::Create
static PThread * Create(const PNotifier &notifier, INT parameter=0, AutoDeleteFlag deletion=AutoDeleteThread, Priority priorityLevel=NormalPriority, const PString &threadName=PString::Empty(), PINDEX stackSize=65536)
Create a simple thread executing the specified notifier.
PThreadObj1Arg::Main
void Main()
User override function for the main execution routine of the thread.
Definition: thread.h:670
PThread1Arg
Definition: thread.h:470
PStack
This template class maps the PAbstractList to a specific object type, and adds functionality that all...
Definition: lists.h:582
PThread::IsAutoDelete
bool IsAutoDelete() const
Definition: thread.h:356
PThreadObj::ObjTypeFn
void(ObjType::* ObjTypeFn)()
Definition: thread.h:600
PThread::Current
static PThread * Current()
Get the currently running thread object instance.
PThread::Restart
virtual void Restart()
Restart a terminated thread using the same stack priority etc that was current when the thread termin...
PThread::AutoDeleteThread
Automatically delete thread object on termination.
Definition: thread.h:91
PThread::IsSuspended
virtual PBoolean IsSuspended() const
Determine if the thread is currently suspended.
PMutex
Synonym for PTimedMutex.
PThread3Arg::FnType
void(* FnType)(Arg1Type arg1, Arg2Type arg2, Arg3Type arg3)
Definition: thread.h:553
PThread::m_originalStackSize
PINDEX m_originalStackSize
Definition: thread.h:376
PThread::SetThreadName
virtual void SetThreadName(const PString &name)
Change the name of the thread.
PThreadObj1Arg::PThreadObj1Arg
PThreadObj1Arg(ObjType &obj, Arg1Type arg1, ObjTypeFn function, bool autoDel=false, const char *name=NULL, PThread::Priority priority=PThread::NormalPriority)
Definition: thread.h:652
PThread::GetPriority
virtual Priority GetPriority() const
Get the current priority of the thread in the current process.
PThreadObj2Arg::Main
void Main()
User override function for the main execution routine of the thread.
Definition: thread.h:708
PThread::PThread
PThread(PINDEX, AutoDeleteFlag deletion=AutoDeleteThread, Priority priorityLevel=NormalPriority, const PString &threadName=PString::Empty())
Create a new thread instance.
psprintf
PString psprintf(const char *fmt,...)
The same as the standard C snprintf(fmt, 1000, ...), but returns a PString instead of a const char *...
PThreadObj1Arg::m_object
ObjType & m_object
Definition: thread.h:676
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PThread::NormalPriority
Normal priority for a thread.
Definition: thread.h:79
PThread3Arg::m_arg1
Arg1Type m_arg1
Definition: thread.h:574
PThread::PExternalThread
friend class PExternalThread
Definition: thread.h:363
PThreadObj2Arg::PThreadObj2Arg
PThreadObj2Arg(ObjType &obj, Arg1Type arg1, Arg2Type arg2, ObjTypeFn function, bool autoDel=false, const char *name=NULL, PThread::Priority priority=PThread::NormalPriority)
Definition: thread.h:688
PThread::Times::m_user
PTimeInterval m_user
Total user CPU time in milliseconds.
Definition: thread.h:299
PThread2Arg::PThread2Arg
PThread2Arg(Arg1Type arg1, Arg2Type arg2, FnType function, bool autoDel=false)
Definition: thread.h:514
PThread::Times::operator<<
friend ostream & operator<<(ostream &strm, const Times &times)
PThread::m_threadId
PThreadIdentifier m_threadId
Definition: thread.h:381
PThread::SetPriority
virtual void SetPriority(Priority priorityLevel)
Set the priority of the thread relative to other threads in the current process.
PThreadObj2Arg::m_function
ObjTypeFn m_function
Definition: thread.h:715
PThreadObj::m_function
ObjTypeFn m_function
Definition: thread.h:625
PThread1Arg::PThread1Arg
PThread1Arg(const char *file, int line, Arg1Type arg1, FnType function, bool autoDel=false)
Definition: thread.h:481
PThread1Arg::m_function
FnType m_function
Definition: thread.h:491