Initial commit of files
This commit is contained in:
81
include/libnet++/Thread.h
Normal file
81
include/libnet++/Thread.h
Normal file
@ -0,0 +1,81 @@
|
||||
//
|
||||
// Linux Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Thread__
|
||||
#define __Thread__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "netlib.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Thread {
|
||||
// public data
|
||||
public:
|
||||
void *m_arg;
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
pthread_t m_thread;
|
||||
pthread_attr_t m_attr;
|
||||
|
||||
// private data
|
||||
private:
|
||||
bool m_join;
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Thread();
|
||||
|
||||
// destructor
|
||||
virtual ~Thread();
|
||||
|
||||
Thread( const Thread& );
|
||||
const Thread& operator=( const Thread& );
|
||||
|
||||
// public methods
|
||||
void Init(void);
|
||||
int Start( void *arg = NULL, bool detach = false );
|
||||
int Stop( void );
|
||||
int Join( void **pptr = NULL );
|
||||
|
||||
pthread_t GetTid(void) {return m_thread;};
|
||||
|
||||
// virtual functions
|
||||
virtual bool Prep(void);
|
||||
virtual void *Run(void *) = 0; // {return NULL;};
|
||||
|
||||
// exceptions
|
||||
class ThreadException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods to override
|
||||
|
||||
// private methods
|
||||
private:
|
||||
// signal catchers (do not override)
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user