信号槽使用mythread
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "exception.h"
|
||||
#include "stdio.h"
|
||||
#include "debug.h"
|
||||
#include "string.h"
|
||||
|
||||
|
||||
|
||||
@@ -30,9 +31,9 @@ static void *p_thread(void *t){
|
||||
throw_("th->func was null.");
|
||||
}
|
||||
th->func(th->arg);
|
||||
}catch_{
|
||||
DBG_WARN("func:%08lx failed.\n",(size_t)th->func);
|
||||
DBG_WARN("file=%s,line=%d,err=%s\n",exception()->file,exception()->line,exception()->log);
|
||||
}catch_ {
|
||||
DBG_WARN("thread(%s)=%08lx failed.\n",th->name,(size_t)th->func);
|
||||
DBG_WARN("%s:%d err(%s)\n",exception()->file,exception()->line,exception()->log);
|
||||
}
|
||||
DBG_INFO("func:%08lx end.\n",(size_t)th->func);
|
||||
th->end=1;
|
||||
@@ -42,11 +43,13 @@ static void *p_thread(void *t){
|
||||
|
||||
|
||||
|
||||
int myth_create(int (*func)(void *t),void *t){
|
||||
pthread_t* myth_create(int (*func)(void *t),void *t,const char *name){
|
||||
myth_def *m=calloc(sizeof(myth_def),1);
|
||||
m->func=func;
|
||||
m->arg=t;
|
||||
pthread_create(&m->th,NULL,p_thread,m);
|
||||
m->arg = t;
|
||||
if(name)
|
||||
strncpy(m->name, name, FUNC_NAME_LEN - 1);
|
||||
pthread_create(&m->th, NULL, p_thread, m);
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
if(s->head==NULL){
|
||||
@@ -60,7 +63,7 @@ int myth_create(int (*func)(void *t),void *t){
|
||||
m->last=myth;
|
||||
}
|
||||
}
|
||||
return m->id;
|
||||
return &m->th;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user