Revert "add mutex and thread abstraction"

This reverts commit 78dd12e2dd.
This commit is contained in:
max_10
2018-09-20 17:45:51 +02:00
committed by Thilo Graf
parent b08367d83a
commit bdf8de2c42
4 changed files with 0 additions and 100 deletions

View File

@@ -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);
}

View File

@@ -1,20 +0,0 @@
#ifndef _MUTEX_ABSTRACTION_H
#define _MUTEX_ABSTRACTION_H
#include <pthread.h>
class Mutex
{
pthread_mutex_t mMutex;
Mutex(const Mutex&);
const Mutex& operator=(const Mutex&);
public:
Mutex();
virtual ~Mutex();
void lock();
void unlock();
};
#endif

View File

@@ -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();
}

View File

@@ -1,25 +0,0 @@
#ifndef _THREAD_ABSTRACTION_H
#define _THREAD_ABSTRACTION_H
#include <pthread.h>
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