Add Ymodem transmit translated to boosts
This commit is contained in:
44
Thread.h
Normal file
44
Thread.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef THREAD_HH
|
||||
#define THREAD_HH
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
template<typename T>
|
||||
class Thread {
|
||||
private:
|
||||
boost::thread* thread;
|
||||
bool isRunning;
|
||||
public:
|
||||
// Ctor
|
||||
Thread() : thread(NULL), isRunning(false) {
|
||||
}
|
||||
virtual ~Thread() {
|
||||
kill();
|
||||
}
|
||||
|
||||
void start() {
|
||||
T* derived = dynamic_cast<T*>(this);
|
||||
thread = new boost::thread(boost::bind(&Thread::doIt, this, boost::ref(*derived)));
|
||||
}
|
||||
void doIt(T& derived) {
|
||||
}
|
||||
bool isFinished() {
|
||||
return isRunning;
|
||||
}
|
||||
void join() {
|
||||
if(thread) {
|
||||
thread->join();
|
||||
}
|
||||
}
|
||||
void kill() {
|
||||
if(thread) {
|
||||
thread->interrupt();
|
||||
delete thread;
|
||||
thread = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
Reference in New Issue
Block a user