A small library that's provide helpers for programmers

Dependents:   PYRN

MyThread.cpp

Committer:
clemounet
Date:
2015-02-17
Revision:
1:ee7a5f05513d
Parent:
0:11d8781f1013
Child:
2:6cc4c56940af

File content as of revision 1:ee7a5f05513d:


#include "MyThread.h"
#include "MyLibc.h"

void MainTrampoline(void const *args){
    MyThread *mt = (MyThread*) args;
    mt->Main();
    mt->t->signal_set(ENDSIG);
    mt->t->terminate();
}

MyThread::MyThread(const char* name){
    tName = strdup(name);
}

MyThread::~MyThread() {
    free((char*)tName);
}

void MyThread::Start(void){
    running = true;
}

void MyThread::Stop(void){
    running = false;
}

void MyThread::Run(void){
    t = new Thread(MainTrampoline,this);
}

void MyThread::Wait(int32_t ms){
    t->wait(ms);
}

void MyThread::WaitEnd(){
    t->signal_wait(ENDSIG);
}