add function sf_enable_thread_notify_ex
parent
46dfd4ad01
commit
115b1e7750
|
|
@ -109,10 +109,11 @@ static inline int set_write_event(struct fast_task_info *task)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int set_read_event(struct fast_task_info *task)
|
int sf_set_read_event(struct fast_task_info *task)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
task->nio_stage = SF_NIO_STAGE_RECV;
|
||||||
if (task->event.callback == (IOEventCallback)sf_client_sock_read) {
|
if (task->event.callback == (IOEventCallback)sf_client_sock_read) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -166,7 +167,7 @@ static int sf_nio_deal_task(struct fast_task_info *task)
|
||||||
result = sf_nio_init(task);
|
result = sf_nio_init(task);
|
||||||
break;
|
break;
|
||||||
case SF_NIO_STAGE_RECV:
|
case SF_NIO_STAGE_RECV:
|
||||||
if ((result=set_read_event(task)) == 0)
|
if ((result=sf_set_read_event(task)) == 0)
|
||||||
{
|
{
|
||||||
sf_client_sock_read(task->event.fd,
|
sf_client_sock_read(task->event.fd,
|
||||||
IOEVENT_READ, task);
|
IOEVENT_READ, task);
|
||||||
|
|
@ -546,8 +547,7 @@ int sf_client_sock_write(int sock, short event, void *arg)
|
||||||
if (task->offset >= task->length) {
|
if (task->offset >= task->length) {
|
||||||
task->offset = 0;
|
task->offset = 0;
|
||||||
task->length = 0;
|
task->length = 0;
|
||||||
task->nio_stage = SF_NIO_STAGE_RECV;
|
if (sf_set_read_event(task) != 0) {
|
||||||
if (set_read_event(task) != 0) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ void sf_task_finish_clean_up(struct fast_task_info *pTask);
|
||||||
|
|
||||||
int sf_nio_notify(struct fast_task_info *pTask, const int stage);
|
int sf_nio_notify(struct fast_task_info *pTask, const int stage);
|
||||||
|
|
||||||
|
int sf_set_read_event(struct fast_task_info *task);
|
||||||
|
|
||||||
void sf_task_switch_thread(struct fast_task_info *pTask,
|
void sf_task_switch_thread(struct fast_task_info *pTask,
|
||||||
const int new_thread_index);
|
const int new_thread_index);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -612,3 +612,16 @@ void sf_set_current_time()
|
||||||
g_sf_global_vars.up_time = g_current_time;
|
g_sf_global_vars.up_time = g_current_time;
|
||||||
srand(g_sf_global_vars.up_time);
|
srand(g_sf_global_vars.up_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sf_enable_thread_notify_ex(SFContext *sf_context, const bool enabled)
|
||||||
|
{
|
||||||
|
struct nio_thread_data *thread_data;
|
||||||
|
struct nio_thread_data *pDataEnd;
|
||||||
|
|
||||||
|
pDataEnd = sf_context->thread_data + sf_context->work_threads;
|
||||||
|
for (thread_data=sf_context->thread_data; thread_data<pDataEnd;
|
||||||
|
thread_data++)
|
||||||
|
{
|
||||||
|
thread_data->notify.enabled = enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,11 @@ void sf_accept_loop_ex(SFContext *sf_context, const bool block);
|
||||||
|
|
||||||
#define sf_accept_loop() sf_accept_loop_ex(&g_sf_context, true)
|
#define sf_accept_loop() sf_accept_loop_ex(&g_sf_context, true)
|
||||||
|
|
||||||
|
void sf_enable_thread_notify_ex(SFContext *sf_context, const bool enabled);
|
||||||
|
|
||||||
|
#define sf_enable_thread_notify(enabled) \
|
||||||
|
sf_enable_thread_notify_ex(&g_sf_context, enabled)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue