Skeleton of application, at least compiles

This commit is contained in:
ftc
2020-11-24 22:48:54 +03:00
parent 988adcec4a
commit bd5a629fde
24 changed files with 1788 additions and 3 deletions
+48
View File
@@ -0,0 +1,48 @@
#include "Thread.h"
void * ftc::Thread::DoRun(void * arg)
{
try {
((Thread*)arg)->is_running = true;
((Thread*)arg)->Run();
}
catch (...) {
}
((Thread*)arg)->is_running = false;
if (((Thread*)arg)->delete_after_finish)
{
delete ((Thread*)arg);
}
return NULL;
}
void ftc::Thread::Run()
{
}
bool ftc::Thread::Start()
{
pthread_attr_t attr;
if (pthread_attr_init(&attr) != 0)
{
return false;
}
if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
{
return false;
}
is_running = true;
if (pthread_create(&thread, &attr, &Thread::DoRun, this) != 0)
{
is_running = false;
return false;
}
return true;
}
void ftc::Thread::Perform(Thread *work)
{
work->delete_after_finish = true;
work->Start();
}