Version: 8.3.0
YACS::BASES::ThreadPT Class Reference

#include <ThreadPT.hxx>

Collaboration diagram for YACS::BASES::ThreadPT:

Public Types

typedef void *(* ThreadJob )(void *)
 

Public Member Functions

 ThreadPT ()
 
 ThreadPT (ThreadJob funcPtr, void *stack, size_t stackSize=0)
 
void go (ThreadJob funcPtr, void *stack, size_t stackSize=0)
 
bool operator== (const ThreadPT &other)
 
void join ()
 

Static Public Member Functions

static void detach ()
 Detach thread to release resources on exit. More...
 
static void exit (void *what)
 
static void sleep (unsigned long usec)
 

Private Attributes

pthread_t _threadId
 

Detailed Description

Definition at line 31 of file ThreadPT.hxx.

Member Typedef Documentation

typedef void*(* YACS::BASES::ThreadPT::ThreadJob)(void *)

Definition at line 34 of file ThreadPT.hxx.

Constructor & Destructor Documentation

ThreadPT::ThreadPT ( )

Definition at line 31 of file ThreadPT.cxx.

32 {
33 }
ThreadPT::ThreadPT ( ThreadJob  funcPtr,
void *  stack,
size_t  stackSize = 0 
)

Definition at line 35 of file ThreadPT.cxx.

References go().

36 {
37  go(funcPtr,stack,stackSize);
38 }

Member Function Documentation

void ThreadPT::detach ( )
static

Detach thread to release resources on exit.

Definition at line 62 of file ThreadPT.cxx.

63 {
64  pthread_detach(pthread_self());
65 }
void ThreadPT::exit ( void *  what)
static

Definition at line 67 of file ThreadPT.cxx.

68 {
69  pthread_exit(what);
70 }
void ThreadPT::go ( ThreadJob  funcPtr,
void *  stack,
size_t  stackSize = 0 
)

Definition at line 40 of file ThreadPT.cxx.

References _threadId.

Referenced by ThreadPT().

41 {
42  int err;
43  void **stackT=(void **) stack;
44  pthread_attr_t attr;
45  pthread_attr_init(&attr);
46  if (stackSize > 0)
47  {
48  err = pthread_attr_setstacksize(&attr, stackSize);
49  if (err != 0) throw Exception("Error when setting thread stack size");
50  }
51  err = pthread_create(&_threadId, &attr, funcPtr, stackT);
52  pthread_attr_destroy(&attr);
53  if(err!=0)throw Exception("Error in thread creation");
54 }
void ThreadPT::join ( )

Definition at line 72 of file ThreadPT.cxx.

References _threadId, and PMMLBasicsTestLauncher::ret.

73 {
74  void *ret;
75  pthread_join(_threadId, &ret);
76 }
bool ThreadPT::operator== ( const ThreadPT other)

Definition at line 56 of file ThreadPT.cxx.

References _threadId.

57 {
58  return pthread_equal(_threadId, other._threadId) != 0;
59 }
void ThreadPT::sleep ( unsigned long  usec)
static

Definition at line 78 of file ThreadPT.cxx.

79 {
80  usleep(usec);
81 }

Member Data Documentation

pthread_t YACS::BASES::ThreadPT::_threadId
private

Definition at line 45 of file ThreadPT.hxx.

Referenced by go(), join(), and operator==().


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