mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
Revert "add mutex and thread abstraction"
This reverts commit 78dd12e2dd
.
This commit is contained in:
@@ -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);
|
|
||||||
}
|
|
@@ -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
|
|
@@ -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();
|
|
||||||
}
|
|
@@ -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
|
|
Reference in New Issue
Block a user