#ifndef __THREAD_H_INCLUDED__
#define __THREAD_H_INCLUDED__

#include <stdint.h>
#include <pthread.h>

static void* ThreadFunction(void*);

class Thread {
	friend void* ThreadFunction(void*);

public:
	Thread(void);
	virtual ~Thread(void);
	bool 			Start(void* = NULL);
    void 			Detach(void);
    void* 			Wait(void);
    void 			Stop(void);
    uint32_t		GetThreadId(void);
    static uint32_t GetCurrentThreadID(void);
    static void 	Sleep(double delay_in_seconds);
    static void		Sleep(uint32_t delay_in_milliseconds);

protected:
	virtual void* 	Run(void* parameter);

private:
	pthread_t		m_threadHandle;
	uint32_t		m_threadID;
	bool			m_started;
	bool			m_detached;
	void*			m_parameter;
};

#endif /* __THREAD_H_INCLUDED__ */
