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__)
37inline std::ostream& operator<<(std::ostream &stream,
38 const ptw32_handle_t &handle) {
47typedef pthread_t ThreadId;
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(); }
179 pthread_t m_thread_id;
Thread(const Options &options=Options())
Create a new thread with the specified thread options.
Definition Thread.cpp:75
virtual ~Thread()
Destructor.
Definition Thread.h:106
virtual bool FastStart()
Start the thread and return immediately.
Definition Thread.cpp:104
std::string Name() const
Return the thread name.
Definition Thread.h:155
virtual bool Start()
Start the thread and wait for the thread to be running.
Definition Thread.cpp:90
bool IsRunning()
Check if the thread is running.
Definition Thread.cpp:169
virtual void * Run()=0
The entry point for the new thread.
ThreadId Id() const
Return the thread id.
Definition Thread.h:146
virtual bool Join(void *ptr=NULL)
Join this thread.
Definition Thread.cpp:158
static ThreadId Self()
Returns the current thread's id.
Definition Thread.h:167
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
Thread options.
Definition Thread.h:60
int policy
The scheduling policy.
Definition Thread.h:73
int priority
The thread priority.
Definition Thread.h:80
int inheritsched
The scheduling mode, either PTHREAD_EXPLICIT_SCHED or PTHREAD_INHERIT_SCHED.
Definition Thread.h:88
std::string name
The name of the thread.
Definition Thread.h:65
Options(const std::string &name="")
Create new thread Options.
Definition Thread.cpp:62