18 #ifndef RAUL_THREAD_HPP
19 #define RAUL_THREAD_HPP
24 #include <boost/utility.hpp>
45 static Thread* create(
const std::string& name=
"")
46 {
return new Thread(name); }
50 {
return new Thread(pthread_self(), name); }
57 void set_scheduling(
int policy,
unsigned int priority);
59 const std::string& name()
const {
return _name; }
60 void set_name(
const std::string& name) { _name = name; }
62 unsigned context()
const {
return _context; }
63 void set_context(
unsigned context) { _context = context; }
66 Thread(
const std::string& name=
"");
67 Thread(pthread_t thread,
const std::string& name=
"");
83 inline static void* _static_run(
void* me) {
84 pthread_setspecific(_thread_key, me);
87 myself->_pthread_exists =
false;
92 static void thread_key_alloc()
94 pthread_key_create(&_thread_key, NULL);
98 static pthread_key_t _thread_key;
101 static pthread_once_t _thread_key_once;
105 bool _pthread_exists;
112 #endif // RAUL_THREAD_HPP
Abstract base class for a thread.
Definition: Thread.hpp:38
static Thread * create_for_this_thread(const std::string &name="")
Must be called from thread.
Definition: Thread.hpp:49
virtual void _run()
Thread function to execute.
Definition: Thread.hpp:77