summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author杨威 <[email protected]>2022-11-30 19:46:56 +0800
committer杨威 <[email protected]>2022-11-30 19:46:56 +0800
commit248c51b5b3d35a8b2e1c6043a840907dd237e495 (patch)
treeb0b3c91e649940ec9e4d313329d960bc7a525ee8
parentfdb30a0bedc3bd25931b062eb2d87caed7dbb4f6 (diff)
🎈 perf(sapp_timer): 增加ev_cnt,包处理线程定时器为0时不调用
-rw-r--r--include/private/sapp_timer_private.h1
-rw-r--r--src/timer/sapp_timer.c8
2 files changed, 8 insertions, 1 deletions
diff --git a/include/private/sapp_timer_private.h b/include/private/sapp_timer_private.h
index ac5c74c..ad07b99 100644
--- a/include/private/sapp_timer_private.h
+++ b/include/private/sapp_timer_private.h
@@ -29,6 +29,7 @@ typedef struct{
//struct event *libev_event[SAPP_MAX_THREADS+1];
pthread_t effective_thread_pid;
int effective_thread_index;
+ int event_cnt;
//int thread_cnt; /* sappƽ̨ʵ�ʲ����߳���, �����stand_alone�߳�, ��̶��洢�����һ��index, ��SAPP_TIMER_MAX_THREADS */
}sapp_timer_handle_inner_t;
diff --git a/src/timer/sapp_timer.c b/src/timer/sapp_timer.c
index bed4443..c552396 100644
--- a/src/timer/sapp_timer.c
+++ b/src/timer/sapp_timer.c
@@ -124,7 +124,7 @@ int sapp_timer_add(sapp_timer_handle sth, sapp_timer_event stev)
}else{
ret = __st_timer_add_offline(inner_h, inner_ev);
}
-
+ inner_h->event_cnt+=1;
return ret;
}
@@ -153,6 +153,7 @@ int sapp_timer_del(sapp_timer_handle sth, sapp_timer_event stev)
free(inner_ev);
}
+ inner_h->event_cnt-=1;
return 0;
}
@@ -217,6 +218,11 @@ void __st_pkt_proc_context_check_timeout(int tid)
return;
}
+ if(inner_h->event_cnt <= 0)
+ {
+ return;
+ }
+
if(0 == MESA_ATOMIC_READ(inner_h->running)){
return;
}