PtThread Class Reference
[Cross-platform threads implementation]

Thread class. More...

Inheritance diagram for PtThread:

WpcAdapter::WpcAdapterInfo

List of all members.

Public Member Functions

 PtThread (DWORD stackSize=4096)
 
 ~PtThread (void)
 
bool Create (LPVOID arg=NULL)
 
bool Run ()
 Starts thread execution.
bool Suspend ()
 Suspends thread execution.
bool Resume ()
 Resumes thread execution.
bool Kill (bool force=false, DWORD timeout=0)
 Finishing thread execution.
bool Wait (DWORD dwMsec=-1)
 Waits for thread shutdown.
bool GetExitCode (DWORD *code)
 Returns thread's exit code.
PtThreadState GetState ()
 Returns thread's state.
bool IsRunning ()
 Returns true if the thread executed now.
PtThreadID ThreadId ()
 Returns ID of the thread, controlled by the object.

Static Public Member Functions

static PtThreadID CurrThreadId ()
 Returns current executed thread ID.
static bool ThreadIdsEqual (PtThreadID *p1, PtThreadID *p2)
 Compares two PtThreadID objects.

Protected Member Functions

bool TestDestroy ()
 Internal function to check the criteria to shutdown.
virtual DWORD Entry (LPVOID arg)
 Thread payload.

Static Private Member Functions

static PtThreadFunc EntryPoint (void *arg)


Detailed Description

Thread class.

Author:
A. Abramov, 13.05.2009.

Constructor & Destructor Documentation

PtThread::PtThread ( DWORD  stackSize = 4096  ) 

Constructs PtThread object. Thread execution not started, even thread itself doesn't created. Only necessary structures are initialized.

Parameters:
stackSize Stack size for the thread.

PtThread::~PtThread ( void   ) 

Destroys object. If thread still running it will be force terminated


Member Function Documentation

bool PtThread::Create ( LPVOID  arg = NULL  ) 

Creates thread in suspended mode, i.e execution will be paused until Run() function will be called.

Parameters:
arg arguments that will be passed to thread function

PtThreadID PtThread::CurrThreadId (  )  [static]

Returns current executed thread ID.

DWORD PtThread::Entry ( LPVOID  arg  )  [protected, virtual]

Thread payload.

Override this function to implement your threaded functionality.
Note: Doesn't call this function immediately from your program .

Parameters:
arg arguments for thread passed to the Create() function

Reimplemented in WpcAdapter::WpcAdapterInfo.

PtThreadFunc PtThread::EntryPoint ( void *  arg  )  [static, private]

This functions used to start thread. To implement your own functionality override Entry() method

bool PtThread::GetExitCode ( DWORD *  code  ) 

Returns thread's exit code.

PtThreadState PtThread::GetState (  )  [inline]

Returns thread's state.

bool PtThread::IsRunning (  )  [inline]

Returns true if the thread executed now.

bool PtThread::Kill ( bool  force = false,
DWORD  timeout = 0 
)

Finishing thread execution.

Parameters:
force if true, then thread will be force closed, even execution not finished yet
timeout milliseconds to wait for thread gracefully shutdown

Todo:
Change PtSleep to wait function to control thread finishing

bool PtThread::Resume (  ) 

Resumes thread execution.

bool PtThread::Run (  ) 

Starts thread execution.

bool PtThread::Suspend (  ) 

Suspends thread execution.

bool PtThread::TestDestroy (  )  [protected]

Internal function to check the criteria to shutdown.

PtThreadID PtThread::ThreadId (  )  [inline]

Returns ID of the thread, controlled by the object.

bool PtThread::ThreadIdsEqual ( PtThreadID *  p1,
PtThreadID *  p2 
) [static]

Compares two PtThreadID objects.

bool PtThread::Wait ( DWORD  dwMsec = -1  ) 

Waits for thread shutdown.

Parameters:
dwMsec milliseconds to wait for thread gracefully shutdown

Todo:
Change PtSleep to wait function to control thread finishing



 
©2009 Positive Technologies
 
Generated on Fri May 22 18:17:01 2009 for wpcObj by 
 
 
1.5.7
 
Get wpcObj at SourceForge.net. Fast, secure and Free Open Source software downloads