mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 15:02:43 +02:00
move libthread to libstb-hal
Origin commit data
------------------
Branch: master
Commit: 95ee7f9e98
Author: smogm <smogm@vh0st.me>
Date: 2015-01-12 (Mon, 12 Jan 2015)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -18,7 +18,5 @@ libcommon_la_SOURCES = \
|
||||
endif
|
||||
|
||||
libcommon_la_SOURCES += \
|
||||
thread_abstraction.cpp \
|
||||
mutex_abstraction.cpp \
|
||||
lt_debug.cpp \
|
||||
proc_tools.c
|
||||
|
@@ -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,34 +0,0 @@
|
||||
#include "thread_abstraction.h"
|
||||
|
||||
SimpleThread::SimpleThread() :
|
||||
mIsRunning(false),
|
||||
mThread()
|
||||
{
|
||||
}
|
||||
|
||||
SimpleThread::~SimpleThread()
|
||||
{
|
||||
// if thread is still running on object destruction, cancel thread the hard way:
|
||||
if (mIsRunning)
|
||||
{
|
||||
pthread_cancel(mThread);
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleThread::startThread()
|
||||
{
|
||||
mIsRunning = true;
|
||||
pthread_create(&mThread, 0, &SimpleThread::runThread, this);
|
||||
}
|
||||
|
||||
void SimpleThread::joinThread()
|
||||
{
|
||||
pthread_join(mThread, 0);
|
||||
mIsRunning = false;
|
||||
}
|
||||
|
||||
void* SimpleThread::runThread(void* ptr)
|
||||
{
|
||||
static_cast<SimpleThread*>(ptr)->run();
|
||||
return 0;
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
#ifndef _SIMPLETHREAD_ABSTRACTION_H
|
||||
#define _SIMPLETHREAD_ABSTRACTION_H
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
class SimpleThread
|
||||
{
|
||||
bool mIsRunning;
|
||||
pthread_t mThread;
|
||||
|
||||
static void* runThread(void*);
|
||||
SimpleThread(const SimpleThread&);
|
||||
const SimpleThread& operator=(const SimpleThread&);
|
||||
|
||||
public:
|
||||
SimpleThread();
|
||||
~SimpleThread();
|
||||
void startThread();
|
||||
void joinThread();
|
||||
|
||||
protected:
|
||||
virtual void run() = 0;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user