-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThreadable.hpp
48 lines (39 loc) · 854 Bytes
/
Threadable.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// Threadable.hpp for plazza in /home/jowett_j//pj/plazza/svn
//
// Made by james jowett
// Login <jowett_j@epitech.net>
//
// Started on Tue Apr 10 05:27:59 2012 james jowett
// Last update Thu Jan 3 22:58:48 2013 WILMOT Pierre
//
#ifndef __THREADABLE_HPP_
#define __THREADABLE_HPP_
#include <stdexcept>
#include <iostream>
#include <cstring>
#include <cerrno>
#include <pthread.h>
#include "Mutex.hpp"
class Threadable
{
public:
Threadable();
~Threadable();
void setMustQuit(bool v);
bool mustQuit();
protected:
void threadIt();
virtual int threadEntryPoint() = 0;
private:
static void *entryPoint(void *);
private:
Mutex m_mustQuitMutex;
volatile bool m_mustQuit;
bool m_launched;
pthread_t m_thread;
private:
Threadable(Threadable const&);
Threadable &operator=(Threadable const&);
};
#endif