CvsiThread Class Reference

#include <vsithread.h>

Public Member Functions

 CvsiThread ()
 ~CvsiThread ()
int IsActive ()
int Create (void *(*StartRoutine)(void *), void *Arg)
int Join (void **Result)
int SetScope (int Scope)

Static Private Member Functions

static void * Thread (void *Arg)

Private Attributes

pthread_t m_Thread
int m_Stat
pthread_attr_t m_Attr
void *(* m_UserRoutine )(void *)
void * m_Arg

Detailed Description

Definition at line 36 of file vsithread.h.


Constructor & Destructor Documentation

CvsiThread::CvsiThread (  ) 

Definition at line 39 of file vsithread.cpp.

00040 {
00041     m_Thread      = 0;
00042     m_Stat        = THREAD_INACTIVE;
00043     pthread_attr_init( &m_Attr );
00044     pthread_attr_setstacksize( &m_Attr, 2*PTHREAD_STACK_MIN );
00045     m_UserRoutine = NULL;
00046     m_Arg         = NULL;
00047 }

CvsiThread::~CvsiThread (  ) 

Definition at line 49 of file vsithread.cpp.

00050 {
00051 
00052 }


Member Function Documentation

int CvsiThread::Create ( void *(*)(void *)  StartRoutine,
void *  Arg 
)

Definition at line 76 of file vsithread.cpp.

00077 {
00078     // Check if thread not running
00079     if(m_Stat == THREAD_ACTIVE)
00080     {
00081         return VSI_ERROR_THREAD_ACTIVE;
00082     }
00083 
00084     m_Stat = THREAD_ACTIVE;
00085 
00086     m_UserRoutine = StartRoutine;
00087     m_Arg = Arg;
00088 
00089     if(pthread_create (&m_Thread, &m_Attr, &Thread, (void*) this) != 0)
00090     {
00091         m_Stat = THREAD_INACTIVE;
00092         return VSI_ERROR_THREAD_CREATE;
00093     }
00094 
00095     return 0;
00096 }

int CvsiThread::IsActive (  ) 

Definition at line 56 of file vsithread.cpp.

00057 {
00058     if(m_Stat == THREAD_ACTIVE)
00059         return true;
00060     else
00061         return false;
00062 }

int CvsiThread::Join ( void **  Result  ) 

Definition at line 100 of file vsithread.cpp.

00101 {
00102     if(m_Stat == THREAD_INACTIVE)
00103         return VSI_ERROR_THREAD_INACTIVE;
00104 
00105 
00106     if( pthread_join (m_Thread, Result) != 0)
00107         return VSI_ERROR_THREAD_JOIN;
00108 
00109     m_Stat = THREAD_INACTIVE;
00110 
00111     return 0;
00112 }

int CvsiThread::SetScope ( int  Scope  ) 

Definition at line 116 of file vsithread.cpp.

00117 {
00118     // Check if thread not running
00119     if(m_Stat == THREAD_ACTIVE)
00120         return VSI_ERROR_THREAD_ACTIVE;
00121 
00122     int sc;
00123 
00124     if(Scope == VSI_THREAD_SCOPE_SYSTEM)
00125         sc = PTHREAD_SCOPE_SYSTEM;
00126     else if(Scope == VSI_THREAD_SCOPE_PROCESS)
00127         sc = PTHREAD_SCOPE_PROCESS;
00128     else
00129         return VSI_ERROR_INVALID_PARAMETER;
00130 
00131     if(pthread_attr_setscope (&m_Attr,sc) != 0)
00132         return  VSI_ERROR_THREAD_SETSCOPE;
00133 
00134     return 0;
00135 }

void * CvsiThread::Thread ( void *  Arg  )  [static, private]

Definition at line 65 of file vsithread.cpp.

00066 {
00067     CvsiThread* t = (CvsiThread*) Arg;
00068     void* Result  = t->m_UserRoutine(t->m_Arg);
00069     // t->m_Stat = THREAD_INACTIVE;
00070     t->m_UserRoutine = NULL;
00071     pthread_exit( Result );
00072 }


Field Documentation

void* CvsiThread::m_Arg [private]

Definition at line 43 of file vsithread.h.

pthread_attr_t CvsiThread::m_Attr [private]

Definition at line 41 of file vsithread.h.

int CvsiThread::m_Stat [private]

Definition at line 40 of file vsithread.h.

pthread_t CvsiThread::m_Thread [private]

Definition at line 39 of file vsithread.h.

void*(* CvsiThread::m_UserRoutine)(void *) [private]

Definition at line 42 of file vsithread.h.


The documentation for this class was generated from the following files:
Generated on Wed Jul 4 16:03:34 2012 for RIO by  doxygen 1.6.3