diff --git a/HISTORY b/HISTORY index 334df13..694fe75 100644 --- a/HISTORY +++ b/HISTORY @@ -1,8 +1,9 @@ -Version 1.06 2014-06-05 +Version 1.06 2014-06-06 * update source code from FastDFS V5.02 * add function short2buff and buff2short * add object memory pool (fast_mblock.h and fast_mblock.c) + * add member thread_loop_callback in nio_thread_data Version 1.05 2012-07-08 * update source code from FastDFS V3.09 diff --git a/src/fast_task_queue.h b/src/fast_task_queue.h index 7eb8f0f..091a6a9 100644 --- a/src/fast_task_queue.h +++ b/src/fast_task_queue.h @@ -19,10 +19,12 @@ #include "ioevent.h" #include "fast_timer.h" +struct nio_thread_data; struct fast_task_info; -typedef int (*TaskFinishCallBack) (struct fast_task_info *pTask); -typedef void (*TaskCleanUpCallBack) (struct fast_task_info *pTask); +typedef int (*ThreadLoopCallback) (struct nio_thread_data *pThreadData); +typedef int (*TaskFinishCallback) (struct fast_task_info *pTask); +typedef void (*TaskCleanUpCallback) (struct fast_task_info *pTask); typedef void (*IOEventCallback) (int sock, short event, void *arg); @@ -39,6 +41,7 @@ struct nio_thread_data struct fast_timer timer; int pipe_fds[2]; struct fast_task_info *deleted_list; + ThreadLoopCallback thread_loop_callback; void *arg; //extra argument pointer }; @@ -52,7 +55,7 @@ struct fast_task_info int length; //data length int offset; //current offset int req_count; //request count - TaskFinishCallBack finish_callback; + TaskFinishCallback finish_callback; struct nio_thread_data *thread_data; struct fast_task_info *next; }; diff --git a/src/ioevent_loop.c b/src/ioevent_loop.c index f2e2938..11b0755 100644 --- a/src/ioevent_loop.c +++ b/src/ioevent_loop.c @@ -38,7 +38,7 @@ static void deal_timeouts(FastTimerEntry *head) } int ioevent_loop(struct nio_thread_data *pThreadData, - IOEventCallback recv_notify_callback, TaskCleanUpCallBack + IOEventCallback recv_notify_callback, TaskCleanUpCallback clean_up_callback, volatile bool *continue_flag) { int result; @@ -109,6 +109,10 @@ int ioevent_loop(struct nio_thread_data *pThreadData, deal_timeouts(&head); } } + + if (pThreadData->thread_loop_callback != NULL) { + pThreadData->thread_loop_callback(pThreadData); + } } return 0; diff --git a/src/ioevent_loop.h b/src/ioevent_loop.h index dbed3a1..f4ea160 100644 --- a/src/ioevent_loop.h +++ b/src/ioevent_loop.h @@ -8,7 +8,7 @@ extern "C" { #endif int ioevent_loop(struct nio_thread_data *pThreadData, - IOEventCallback recv_notify_callback, TaskCleanUpCallBack + IOEventCallback recv_notify_callback, TaskCleanUpCallback clean_up_callback, volatile bool *continue_flag); int ioevent_set(struct fast_task_info *pTask, struct nio_thread_data *pThread,