From bdf8de2c4246a7bc6a2d0cb6f0ded82de356e87d Mon Sep 17 00:00:00 2001 From: max_10 Date: Thu, 20 Sep 2018 17:45:51 +0200 Subject: [PATCH] Revert "add mutex and thread abstraction" This reverts commit 78dd12e2dd8b9661c4e749bb547e606aa530cf01. --- generic-pc/mutex_abstraction.cpp | 22 --------------------- generic-pc/mutex_abstraction.h | 20 ------------------- generic-pc/thread_abstraction.cpp | 33 ------------------------------- generic-pc/thread_abstraction.h | 25 ----------------------- 4 files changed, 100 deletions(-) delete mode 100644 generic-pc/mutex_abstraction.cpp delete mode 100644 generic-pc/mutex_abstraction.h delete mode 100644 generic-pc/thread_abstraction.cpp delete mode 100644 generic-pc/thread_abstraction.h diff --git a/generic-pc/mutex_abstraction.cpp b/generic-pc/mutex_abstraction.cpp deleted file mode 100644 index a5a886f..0000000 --- a/generic-pc/mutex_abstraction.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "mutex_abstraction.h" - -Mutex::Mutex() : - mMutex() -{ - pthread_mutex_init(&mMutex, 0); -} - -Mutex::~Mutex() -{ - pthread_mutex_destroy(&mMutex); -} - -void Mutex::lock() -{ - pthread_mutex_lock(&mMutex); -} - -void Mutex::unlock() -{ - pthread_mutex_unlock(&mMutex); -} diff --git a/generic-pc/mutex_abstraction.h b/generic-pc/mutex_abstraction.h deleted file mode 100644 index c2b78d8..0000000 --- a/generic-pc/mutex_abstraction.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _MUTEX_ABSTRACTION_H -#define _MUTEX_ABSTRACTION_H - -#include - -class Mutex -{ - pthread_mutex_t mMutex; - - Mutex(const Mutex&); - const Mutex& operator=(const Mutex&); - - public: - Mutex(); - virtual ~Mutex(); - void lock(); - void unlock(); -}; - -#endif diff --git a/generic-pc/thread_abstraction.cpp b/generic-pc/thread_abstraction.cpp deleted file mode 100644 index 57b7759..0000000 --- a/generic-pc/thread_abstraction.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "thread_abstraction.h" - -Thread::Thread() : - mIsRunning(false), - mThread() -{ -} - -Thread::~Thread() -{ - // if thread is still running on object destruction, cancel thread the hard way: - if (mIsRunning) - { - pthread_cancel(mThread); - } -} - -void Thread::startThread() -{ - mIsRunning = true; - pthread_create(&mThread, 0, &Thread::runThread, this); -} - -void Thread::joinThread() -{ - pthread_join(mThread, 0); - mIsRunning = false; -} - -void* Thread::runThread(void* ptr) -{ - ((Thread*)ptr)->run(); -} diff --git a/generic-pc/thread_abstraction.h b/generic-pc/thread_abstraction.h deleted file mode 100644 index 3c3e35f..0000000 --- a/generic-pc/thread_abstraction.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _THREAD_ABSTRACTION_H -#define _THREAD_ABSTRACTION_H - -#include - -class Thread -{ - bool mIsRunning; - pthread_t mThread; - - static void* runThread(void*); - Thread(const Thread&); - const Thread& operator=(const Thread&); - - public: - Thread(); - ~Thread(); - void startThread(); - void joinThread(); - - protected: - virtual void run() = 0; -}; - -#endif