Add Ymodem transmit translated to boosts

This commit is contained in:
2021-08-24 16:21:38 +02:00
parent ac26fc6bdd
commit 2b2cbe655d
16 changed files with 1077 additions and 1806 deletions

44
Thread.h Normal file
View 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