| 
									
										
										
										
											2025-06-24 10:09:14 +08:00
										 |  |  | #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; | 
					
						
							| 
									
										
										
										
											2025-06-25 11:29:06 +08:00
										 |  |  |   pthread_t *tid; | 
					
						
							| 
									
										
										
										
											2025-06-24 10:09:14 +08:00
										 |  |  |   slot_list_with_pars *slot_head; | 
					
						
							|  |  |  | } mythread_t; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |   void* next; | 
					
						
							|  |  |  |   void (*func)(void* par); | 
					
						
							| 
									
										
										
										
											2025-06-24 16:32:32 +08:00
										 |  |  |   void* signal_func; | 
					
						
							| 
									
										
										
										
											2025-06-24 10:09:14 +08:00
										 |  |  |   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); | 
					
						
							| 
									
										
										
										
											2025-06-25 11:29:06 +08:00
										 |  |  | mythread_t* sigthread_init(const char* name); | 
					
						
							| 
									
										
										
										
											2025-06-24 10:09:14 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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
 |