Public Member Functions | Public Attributes | Static Protected Member Functions | Protected Attributes

Thread Struct Reference

Thread base class. More...

#include <utility.h>

Inheritance diagram for Thread:
Inheritance graph
Collaboration diagram for Thread:
Collaboration graph

List of all members.

Public Member Functions

 Thread ()
virtual ~Thread ()
void Start ()
void Stop ()
virtual int Run ()=0
bool is_alive () const

Public Attributes

CritSect _crit_sect

Static Protected Member Functions

static DWORD WINAPI ThreadProc (void *para)

Protected Attributes

HANDLE _hThread
HANDLE _evtFinish
bool _alive
bool _destroy

Detailed Description

Thread base class.

Definition at line 345 of file utility.h.

Constructor & Destructor Documentation

Thread::Thread (  ) [inline]

Definition at line 347 of file utility.h.

     :  _alive(false),
        _hThread = INVALID_HANDLE_VALUE;
        _evtFinish = CreateEvent(NULL, TRUE, FALSE, NULL);
virtual Thread::~Thread (  ) [inline, virtual]

Definition at line 355 of file utility.h.



        if (_destroy)
            delete this;

Member Function Documentation

bool Thread::is_alive (  ) const [inline]

Definition at line 391 of file utility.h.

Referenced by FindProgramDlg::collect_programs_callback().

{return _alive;}

Here is the caller graph for this function:

virtual int Thread::Run (  ) [pure virtual]

Implemented in CollectProgramsThread.

Referenced by ThreadProc().

Here is the caller graph for this function:

void Thread::Start (  ) [inline]

Definition at line 366 of file utility.h.

Referenced by _tWinMain(), and FindProgramDlg::Refresh().

        if (!_alive) {
            _alive = true;
            _hThread = CreateThread(NULL, 0, ThreadProc, this, 0, NULL);

Here is the caller graph for this function:

void Thread::Stop (  ) [inline]

Definition at line 374 of file utility.h.

Referenced by _tWinMain(), FindProgramDlg::Refresh(), and FindProgramDlg::~FindProgramDlg().


        if (_alive) {
            Lock lock(_crit_sect);
            _alive = false;

             // wait for finishing
            WaitForSingleObject(_hThread, INFINITE);

Here is the caller graph for this function:

DWORD WINAPI Thread::ThreadProc ( void *  para ) [static, protected]

Definition at line 37 of file utility.cpp.

References _alive, and Run().

    Thread* pThis = (Thread*) para;

    int ret = pThis->Run();

    pThis->_alive = false;

    return ret;

Here is the call graph for this function:

Member Data Documentation

bool Thread::_alive [protected]
bool Thread::_destroy [protected]

Definition at line 401 of file utility.h.

HANDLE Thread::_evtFinish [protected]

Definition at line 399 of file utility.h.

HANDLE Thread::_hThread [protected]

Definition at line 398 of file utility.h.

The documentation for this struct was generated from the following files:

ROS Explorer Source Code Documentation
generated on 02.01.2013 by doxygen

ROS Explorer Homepage