blob: 1e94777683a61a2eaa9db8e22f1b8f30f13e60eb [file] [log] [blame]
Austin Schuh9b360e92013-03-27 04:47:04 +00001#ifndef THREAD_H_
2#define THREAD_H_
3
4#include <sys/socket.h>
5#include <linux/can.h>
6#include <boost/thread/locks.hpp>
7#include <boost/thread.hpp>
8
9class Thread {
10 public:
11 // Constructer initializes terminate to false.
12 Thread() : should_terminate_(false) {}
13
14 // Terminate the thread soon.
15 void Terminate();
16
17 protected:
18 // Helper method to atomically read the should_terminate_ boolean.
19 bool should_run();
20
21 private:
22 // Stores whether or not the thread has been asked to quit.
23 // TODO(aschuh): This really should be a Notification...
24 bool should_terminate_;
25 // Mutex to protect should_terminate.
26 boost::mutex terminate_mutex_;
27};
28
29#endif // THREAD_H_