add function locked_list_count

storage_pool
YuQing 2021-04-12 15:31:59 +08:00
parent 6a3bcd4547
commit 76ef22d380
2 changed files with 14 additions and 0 deletions

View File

@ -32,6 +32,11 @@ 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);
static inline bool ioevent_is_canceled(struct fast_task_info *task)
{
return __sync_fetch_and_add(&task->canceled, 0) != 0;
}
//only called by the nio thread
static inline void ioevent_add_to_deleted_list(struct fast_task_info *task)
{

View File

@ -48,6 +48,15 @@ extern "C" {
PTHREAD_MUTEX_UNLOCK(&list->lock);
}
static inline int locked_list_count(FCLockedList *list)
{
int count;
PTHREAD_MUTEX_LOCK(&list->lock);
count = fc_list_count(&list->head);
PTHREAD_MUTEX_UNLOCK(&list->lock);
return count;
}
#ifdef __cplusplus
}
#endif