21 #ifndef INCLUDE_OLA_THREAD_THREAD_H_ 22 #define INCLUDE_OLA_THREAD_THREAD_H_ 28 #define WIN32_LEAN_AND_MEAN 32 #include <ola/thread/Mutex.h> 36 #if defined(_WIN32) && defined(__GNUC__) 37 inline std::ostream&
operator<<(std::ostream &stream,
38 const ptw32_handle_t &handle) {
42 #endif // defined(_WIN32) && defined(__GNUC__) 47 typedef pthread_t ThreadId;
94 explicit Options(
const std::string &name =
"");
115 virtual bool Start();
131 virtual bool Join(
void *ptr = NULL);
146 ThreadId
Id()
const {
return m_thread_id; }
155 std::string
Name()
const {
return m_options.name; }
161 void* _InternalRun();
167 static inline ThreadId
Self() {
return pthread_self(); }
176 virtual void *
Run() = 0;
179 pthread_t m_thread_id;
189 #endif // INCLUDE_OLA_THREAD_THREAD_H_ virtual bool Join(void *ptr=NULL)
Join this thread.
Definition: Thread.cpp:158
virtual void * Run()=0
The entry point for the new thread.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Creates dummy copy constructor and assignment operator declarations.
Definition: Macro.h:44
Thread(const Options &options=Options())
Create a new thread with the specified thread options.
Definition: Thread.cpp:75
Options(const std::string &name="")
Create new thread Options.
Definition: Thread.cpp:62
virtual ~Thread()
Destructor.
Definition: Thread.h:106
std::string Name() const
Return the thread name.
Definition: Thread.h:155
std::ostream & operator<<(std::ostream &out, const DmxBuffer &data)
Stream operator to allow DmxBuffer to be output to stdout.
Definition: DmxBuffer.cpp:402
virtual bool Start()
Start the thread and wait for the thread to be running.
Definition: Thread.cpp:90
int inheritsched
The scheduling mode, either PTHREAD_EXPLICIT_SCHED or PTHREAD_INHERIT_SCHED.
Definition: Thread.h:88
int policy
The scheduling policy.
Definition: Thread.h:73
virtual bool FastStart()
Start the thread and return immediately.
Definition: Thread.cpp:104
Thread options.
Definition: Thread.h:60
int priority
The thread priority.
Definition: Thread.h:80
bool IsRunning()
Check if the thread is running.
Definition: Thread.cpp:169
ThreadId Id() const
Return the thread id.
Definition: Thread.h:146
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
std::string name
The name of the thread.
Definition: Thread.h:65
static ThreadId Self()
Returns the current thread's id.
Definition: Thread.h:167