diff options
Diffstat (limited to 'raul')
-rw-r--r-- | raul/Slave.hpp | 1 | ||||
-rw-r--r-- | raul/Thread.hpp | 27 |
2 files changed, 6 insertions, 22 deletions
diff --git a/raul/Slave.hpp b/raul/Slave.hpp index a301bc4..95bff5c 100644 --- a/raul/Slave.hpp +++ b/raul/Slave.hpp @@ -18,7 +18,6 @@ #ifndef RAUL_SLAVE_HPP #define RAUL_SLAVE_HPP -#include <pthread.h> #include "raul/Semaphore.hpp" #include "raul/Thread.hpp" diff --git a/raul/Thread.hpp b/raul/Thread.hpp index ecd896e..bc469f4 100644 --- a/raul/Thread.hpp +++ b/raul/Thread.hpp @@ -21,12 +21,12 @@ #include <set> #include <string> -#include <pthread.h> - #include "raul/Noncopyable.hpp" namespace Raul { +struct ThreadImpl; + /** Abstract base class for a thread. * * Extend this and override the _run method to easily create a thread @@ -39,16 +39,12 @@ namespace Raul { class Thread : Noncopyable { public: - virtual ~Thread() { - stop(); - } + virtual ~Thread(); static Thread* create(const std::string& name="") { return new Thread(name); } - /** Must be called from thread */ - static Thread* create_for_this_thread(const std::string& name="") - { return new Thread(pthread_self(), name); } + static Thread* create_for_this_thread(const std::string& name=""); static Thread& get(); @@ -84,22 +80,11 @@ protected: private: static void* _static_run(void* me); - /** Allocate thread-specific data key */ - static void thread_key_alloc() { - pthread_key_create(&_thread_key, NULL); - } - - /* Key for the thread-specific buffer */ - static pthread_key_t _thread_key; - - /* Once-only initialisation of the key */ - static pthread_once_t _thread_key_once; - + ThreadImpl* _impl; std::set<unsigned> _contexts; std::string _name; - bool _pthread_exists; + bool _thread_exists; bool _own_thread; - pthread_t _pthread; }; } // namespace Raul |