Initial commit

This commit is contained in:
NightBits
2018-12-19 20:25:07 +01:00
parent 29d0adaa45
commit dab50aaf41
18 changed files with 1716 additions and 2 deletions

58
CrossThreadsHandler.cpp Normal file
View File

@@ -0,0 +1,58 @@
// CrossThreadsHandler
// Copyright Jeroen Saey
// Created 29-01-2013
// CrossThreadsHandler.cpp
#include "CrossThreadsHandler.h"
#include <sstream>
#include <iostream>
#include <errno.h>
using namespace std;
CrossThreadsHandler::CrossThreadsHandler()
{
}
unsigned long CrossThreadsHandler::createAndStartThread(threadCallBack callback)
{
CrossThreads *thread = new CrossThreads(callback);
thread->create();
_threadList.insert(pair<unsigned long, CrossThreads*>(thread->getThreadID(),thread));
return thread->getThreadID();
}
bool CrossThreadsHandler::joinThread(unsigned long threadID)
{
map <unsigned long, CrossThreads*>::iterator iterator = _threadList.find(threadID);
if (iterator != _threadList.end())
{
iterator->second->join();
return true;
}
else
{
cout << "The client could not be found in the threadList.";
return false;
}
}
bool CrossThreadsHandler::removeThread(unsigned long threadID)
{
map <unsigned long, CrossThreads*>::iterator iterator = _threadList.find(threadID);
if (iterator != _threadList.end())
{
_threadList.erase(iterator);
return true;
}
else
{
cout << "The client could not be found in the threadList.";
return false;
}
}
CrossThreadsHandler::~CrossThreadsHandler()
{
}