add member thread_loop_callback in nio_thread_data

pull/1/head
yuqing 2014-06-06 18:31:06 +08:00
parent f4dacfda98
commit b0494666ad
4 changed files with 14 additions and 6 deletions

View File

@ -1,8 +1,9 @@
Version 1.06 2014-06-05 Version 1.06 2014-06-06
* update source code from FastDFS V5.02 * update source code from FastDFS V5.02
* add function short2buff and buff2short * add function short2buff and buff2short
* add object memory pool (fast_mblock.h and fast_mblock.c) * 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 Version 1.05 2012-07-08
* update source code from FastDFS V3.09 * update source code from FastDFS V3.09

View File

@ -19,10 +19,12 @@
#include "ioevent.h" #include "ioevent.h"
#include "fast_timer.h" #include "fast_timer.h"
struct nio_thread_data;
struct fast_task_info; struct fast_task_info;
typedef int (*TaskFinishCallBack) (struct fast_task_info *pTask); typedef int (*ThreadLoopCallback) (struct nio_thread_data *pThreadData);
typedef void (*TaskCleanUpCallBack) (struct fast_task_info *pTask); 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); typedef void (*IOEventCallback) (int sock, short event, void *arg);
@ -39,6 +41,7 @@ struct nio_thread_data
struct fast_timer timer; struct fast_timer timer;
int pipe_fds[2]; int pipe_fds[2];
struct fast_task_info *deleted_list; struct fast_task_info *deleted_list;
ThreadLoopCallback thread_loop_callback;
void *arg; //extra argument pointer void *arg; //extra argument pointer
}; };
@ -52,7 +55,7 @@ struct fast_task_info
int length; //data length int length; //data length
int offset; //current offset int offset; //current offset
int req_count; //request count int req_count; //request count
TaskFinishCallBack finish_callback; TaskFinishCallback finish_callback;
struct nio_thread_data *thread_data; struct nio_thread_data *thread_data;
struct fast_task_info *next; struct fast_task_info *next;
}; };

View File

@ -38,7 +38,7 @@ static void deal_timeouts(FastTimerEntry *head)
} }
int ioevent_loop(struct nio_thread_data *pThreadData, 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) clean_up_callback, volatile bool *continue_flag)
{ {
int result; int result;
@ -109,6 +109,10 @@ int ioevent_loop(struct nio_thread_data *pThreadData,
deal_timeouts(&head); deal_timeouts(&head);
} }
} }
if (pThreadData->thread_loop_callback != NULL) {
pThreadData->thread_loop_callback(pThreadData);
}
} }
return 0; return 0;

View File

@ -8,7 +8,7 @@ extern "C" {
#endif #endif
int ioevent_loop(struct nio_thread_data *pThreadData, 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); clean_up_callback, volatile bool *continue_flag);
int ioevent_set(struct fast_task_info *pTask, struct nio_thread_data *pThread, int ioevent_set(struct fast_task_info *pTask, struct nio_thread_data *pThread,