Initial commit of files
This commit is contained in:
72
include/libnet++/Mutex.h
Normal file
72
include/libnet++/Mutex.h
Normal file
@ -0,0 +1,72 @@
|
||||
//
|
||||
// Linux Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Mutex__
|
||||
#define __Mutex__
|
||||
|
||||
/* 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>
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Mutex {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
pthread_mutexattr_t m_attr;
|
||||
pthread_mutex_t m_mutex;
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Mutex();
|
||||
|
||||
// destructor
|
||||
virtual ~Mutex();
|
||||
|
||||
Mutex( const Mutex& );
|
||||
const Mutex& operator=( const Mutex& );
|
||||
|
||||
// public methods
|
||||
void Init( void );
|
||||
int Lock( void );
|
||||
int TryLock( void );
|
||||
int Unlock( void );
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
class MutexException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods to override
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user