Files
c_soft/soft/mysignal.h
2025-06-25 11:29:06 +08:00

56 lines
1.1 KiB
C

#ifndef mysignal_h__
#define mysignal_h__
#include "pthread.h"
#include "stdint.h"
#include <semaphore.h>
#define emit
#define signal void
#define slot void
typedef struct {
void* next;
void (*func)(void* par);
// size_t pars[]; // 这里保存函数的参数实体
}slot_list_with_pars;
typedef struct {
pthread_mutex_t lock; /* 互斥锁定义 */
sem_t sem;
pthread_t *tid;
slot_list_with_pars *slot_head;
} mythread_t;
typedef struct {
void* next;
void (*func)(void* par);
void* signal_func;
void* slot_obj;
mythread_t* thread;
}slot_list;
typedef struct {
pthread_mutex_t lock; /* 互斥锁定义 */
slot_list* slot_head;
}__SIG_OBJ;
#define SIG_OBJ __SIG_OBJ __sig_obj
void send_slot_fun(mythread_t* self, slot_list_with_pars* slot_p);
mythread_t* sigthread_init(const char* name);
void _connect(void* sig_obj, void* sig_fun, mythread_t* thread, void* slot_obj, const char* slot_fun);
// 这个函数在signal_tmp.c里实现
void* signal_find_slot_func(const char* name);
#define connect(sig_obj, sig_fun, thread, slot_obj, slot_fun) {\
(void)slot_fun;\
_connect(sig_obj, sig_fun, thread, slot_obj, #slot_fun);}\
#endif