summaryrefslogtreecommitdiff
path: root/src/threading
diff options
context:
space:
mode:
Diffstat (limited to 'src/threading')
-rw-r--r--src/threading/event.cpp1
-rw-r--r--src/threading/event.h3
-rw-r--r--src/threading/thread.cpp7
-rw-r--r--src/threading/thread.h20
4 files changed, 14 insertions, 17 deletions
diff --git a/src/threading/event.cpp b/src/threading/event.cpp
index 4e8d4bb3e..885e732c8 100644
--- a/src/threading/event.cpp
+++ b/src/threading/event.cpp
@@ -24,6 +24,7 @@ DEALINGS IN THE SOFTWARE.
*/
#include "threading/event.h"
+#include "threading/mutex_auto_lock.h"
void Event::wait()
{
diff --git a/src/threading/event.h b/src/threading/event.h
index 458864c82..af91d04c7 100644
--- a/src/threading/event.h
+++ b/src/threading/event.h
@@ -26,10 +26,7 @@ DEALINGS IN THE SOFTWARE.
#ifndef THREADING_EVENT_H
#define THREADING_EVENT_H
-#include "threads.h"
-
#include <condition_variable>
-#include "threading/mutex_auto_lock.h"
/** A syncronization primitive that will wake up one waiting thread when signaled.
* Calling @c signal() multiple times before a waiting thread has had a chance
diff --git a/src/threading/thread.cpp b/src/threading/thread.cpp
index e566824f7..cc4d65656 100644
--- a/src/threading/thread.cpp
+++ b/src/threading/thread.cpp
@@ -180,10 +180,8 @@ bool Thread::getReturnValue(void **ret)
}
-void *Thread::threadProc(void *param)
+void Thread::threadProc(Thread *thr)
{
- Thread *thr = (Thread *)param;
-
#ifdef _AIX
thr->m_kernel_thread_id = thread_self();
#endif
@@ -201,9 +199,6 @@ void *Thread::threadProc(void *param)
thr->m_running = false;
g_logger.deregisterThread();
-
- // 0 is returned here to avoid an unnecessary ifdef clause
- return 0;
}
diff --git a/src/threading/thread.h b/src/threading/thread.h
index 6292d9ed7..284c8e46c 100644
--- a/src/threading/thread.h
+++ b/src/threading/thread.h
@@ -26,10 +26,10 @@ DEALINGS IN THE SOFTWARE.
#pragma once
#include "util/basic_macros.h"
-#include "threads.h"
#include <string>
#include <atomic>
+#include <thread>
#include <mutex>
#ifdef _AIX
@@ -49,10 +49,12 @@ DEALINGS IN THE SOFTWARE.
#endif
+
class Thread {
public:
Thread(const std::string &name="");
virtual ~Thread();
+ DISABLE_CLASS_COPY(Thread)
/*
* Begins execution of a new thread at the pure virtual method Thread::run().
@@ -87,13 +89,12 @@ public:
/*
* Returns true if the calling thread is this Thread object.
*/
- bool isCurrentThread() { return thr_is_current_thread(getThreadId()); }
+ bool isCurrentThread() { return std::this_thread::get_id() == getThreadId(); }
- inline bool isRunning() { return m_running; }
- inline bool stopRequested() { return m_request_stop; }
+ bool isRunning() { return m_running; }
+ bool stopRequested() { return m_request_stop; }
- inline threadid_t getThreadId() { return m_thread_obj->get_id(); }
- inline threadhandle_t getThreadHandle() { return m_thread_obj->native_handle(); }
+ std::thread::id getThreadId() { return m_thread_obj->get_id(); }
/*
* Gets the thread return value.
@@ -139,6 +140,11 @@ protected:
virtual void *run() = 0;
private:
+ std::thread::native_handle_type getThreadHandle()
+ { return m_thread_obj->native_handle(); }
+
+ static void threadProc(Thread *thr);
+
void *m_retval;
bool m_joinable;
std::atomic<bool> m_request_stop;
@@ -148,13 +154,11 @@ private:
std::thread *m_thread_obj;
- static ThreadStartFunc threadProc;
#ifdef _AIX
// For AIX, there does not exist any mapping from pthread_t to tid_t
// available to us, so we maintain one ourselves. This is set on thread start.
tid_t m_kernel_thread_id;
#endif
- Thread(const Thread &) = delete;
};