A small library that's provide helpers for programmers

Dependents:   PYRN

Committer:
clemounet
Date:
Tue Feb 17 11:55:34 2015 +0000
Revision:
1:ee7a5f05513d
Parent:
0:11d8781f1013
Child:
2:6cc4c56940af
more Things

Who changed what in which revision?

UserRevisionLine numberNew contents of line
clemounet 0:11d8781f1013 1
clemounet 1:ee7a5f05513d 2 #include "MyThread.h"
clemounet 1:ee7a5f05513d 3 #include "MyLibc.h"
clemounet 0:11d8781f1013 4
clemounet 0:11d8781f1013 5 void MainTrampoline(void const *args){
clemounet 0:11d8781f1013 6 MyThread *mt = (MyThread*) args;
clemounet 0:11d8781f1013 7 mt->Main();
clemounet 0:11d8781f1013 8 mt->t->signal_set(ENDSIG);
clemounet 0:11d8781f1013 9 mt->t->terminate();
clemounet 0:11d8781f1013 10 }
clemounet 0:11d8781f1013 11
clemounet 0:11d8781f1013 12 MyThread::MyThread(const char* name){
clemounet 1:ee7a5f05513d 13 tName = strdup(name);
clemounet 0:11d8781f1013 14 }
clemounet 0:11d8781f1013 15
clemounet 0:11d8781f1013 16 MyThread::~MyThread() {
clemounet 0:11d8781f1013 17 free((char*)tName);
clemounet 0:11d8781f1013 18 }
clemounet 0:11d8781f1013 19
clemounet 0:11d8781f1013 20 void MyThread::Start(void){
clemounet 0:11d8781f1013 21 running = true;
clemounet 0:11d8781f1013 22 }
clemounet 0:11d8781f1013 23
clemounet 0:11d8781f1013 24 void MyThread::Stop(void){
clemounet 0:11d8781f1013 25 running = false;
clemounet 0:11d8781f1013 26 }
clemounet 0:11d8781f1013 27
clemounet 0:11d8781f1013 28 void MyThread::Run(void){
clemounet 0:11d8781f1013 29 t = new Thread(MainTrampoline,this);
clemounet 0:11d8781f1013 30 }
clemounet 0:11d8781f1013 31
clemounet 0:11d8781f1013 32 void MyThread::Wait(int32_t ms){
clemounet 0:11d8781f1013 33 t->wait(ms);
clemounet 0:11d8781f1013 34 }
clemounet 0:11d8781f1013 35
clemounet 0:11d8781f1013 36 void MyThread::WaitEnd(){
clemounet 0:11d8781f1013 37 t->signal_wait(ENDSIG);
clemounet 0:11d8781f1013 38 }