add functions: fc_queue_push_queue_to_tail etc.

storage_pool
YuQing 2021-04-07 14:53:29 +08:00
parent 097a7db3cb
commit c1bb9d6532
3 changed files with 51 additions and 2 deletions

View File

@ -1,11 +1,12 @@
Version 1.49 2021-03-28
Version 1.49 2021-04-07
* add macros: FC_ABS and FC_NEGATIVE
* uniq_skiplist.c: add uniq_skiplist_pair struct and init function
* add functions: fc_mkdirs and str_replace
* add FilenameString type and macro
* add functions: fc_string_case_compare, fc_string_case_equal etc.
* add functions: fc_check_filename_ex
* add function: fc_check_filename_ex
* add functions: fc_queue_push_queue_to_tail etc.
Version 1.48 2021-02-01
* fast_buffer.[hc]: add function fast_buffer_append_binary

View File

@ -135,6 +135,26 @@ void fc_queue_push_queue_to_head_ex(struct fc_queue *queue,
PTHREAD_MUTEX_UNLOCK(&queue->lc_pair.lock);
}
void fc_queue_push_queue_to_tail_ex(struct fc_queue *queue,
struct fc_queue_info *qinfo, bool *notify)
{
if (qinfo->head == NULL) {
*notify = false;
return;
}
PTHREAD_MUTEX_LOCK(&queue->lc_pair.lock);
if (queue->head == NULL) {
queue->head = qinfo->head;
*notify = true;
} else {
FC_QUEUE_NEXT_PTR(queue, queue->tail) = qinfo->head;
*notify = false;
}
queue->tail = qinfo->tail;
PTHREAD_MUTEX_UNLOCK(&queue->lc_pair.lock);
}
void fc_queue_pop_to_queue(struct fc_queue *queue,
struct fc_queue_info *qinfo)
{

View File

@ -93,6 +93,34 @@ static inline void fc_queue_push_queue_to_head(struct fc_queue *queue,
}
}
static inline void fc_queue_push_queue_to_head_silence(
struct fc_queue *queue, struct fc_queue_info *qinfo)
{
bool notify;
fc_queue_push_queue_to_head_ex(queue, qinfo, &notify);
}
void fc_queue_push_queue_to_tail_ex(struct fc_queue *queue,
struct fc_queue_info *qinfo, bool *notify);
static inline void fc_queue_push_queue_to_tail(struct fc_queue *queue,
struct fc_queue_info *qinfo)
{
bool notify;
fc_queue_push_queue_to_tail_ex(queue, qinfo, &notify);
if (notify) {
pthread_cond_signal(&(queue->lc_pair.cond));
}
}
static inline void fc_queue_push_queue_to_tail_silence(
struct fc_queue *queue, struct fc_queue_info *qinfo)
{
bool notify;
fc_queue_push_queue_to_tail_ex(queue, qinfo, &notify);
}
void *fc_queue_pop_ex(struct fc_queue *queue, const bool blocked);
#define fc_queue_pop(queue) fc_queue_pop_ex(queue, true)
#define fc_queue_try_pop(queue) fc_queue_pop_ex(queue, false)