fast_task_info add fields: reffer_count and continue_callback

pull/37/head
YuQing 2020-10-28 11:59:37 +08:00
parent d54007f79b
commit 1ac8c8f3c2
3 changed files with 7 additions and 9 deletions

View File

@ -1,5 +1,5 @@
Version 1.44 2020-10-21
Version 1.44 2020-10-28
* add test file src/tests/test_pthread_lock.c
* add uniq_skiplist.[hc]
* add function split_string_ex

View File

@ -87,7 +87,9 @@ struct fast_task_info
uint8_t current;
volatile uint8_t notify;
} nio_stages; //stages for network IO
bool canceled; //if task canceled
int (*continue_callback)(struct fast_task_info *task); //for continue stage
volatile int8_t reffer_count;
volatile int8_t canceled; //if task canceled
int connect_timeout; //for client side
int network_timeout;
int64_t req_count; //request count

View File

@ -32,20 +32,16 @@ int ioevent_remove(IOEventPoller *ioevent, void *data);
int ioevent_set(struct fast_task_info *pTask, struct nio_thread_data *pThread,
int sock, short event, IOEventCallback callback, const int timeout);
//only called by the nio thread
static inline void ioevent_add_to_deleted_list(struct fast_task_info *task)
{
if (task->thread_data == NULL)
if (!__sync_bool_compare_and_swap(&task->canceled, 0, 1))
{
return;
}
if (task->canceled) {
logError("file: "__FILE__", line: %d, "
logWarning("file: "__FILE__", line: %d, "
"task %p already canceled", __LINE__, task);
return;
}
task->canceled = true;
task->next = task->thread_data->deleted_list;
task->thread_data->deleted_list = task;
}