add function common_blocked_queue_push_chain
parent
47fb7b2abd
commit
88ad619902
1
HISTORY
1
HISTORY
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
Version 1.61 2022-09-21
|
||||
* get_base_path_from_conf_file_ex support parameter: noent_log_level
|
||||
* add function common_blocked_queue_push_chain
|
||||
|
||||
Version 1.60 2022-08-27
|
||||
* normalize_path for base_path
|
||||
|
|
|
|||
|
|
@ -102,6 +102,29 @@ int common_blocked_queue_push_ex(struct common_blocked_queue *queue,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void common_blocked_queue_push_chain_ex(struct common_blocked_queue *queue,
|
||||
struct common_blocked_chain *chain, bool *notify)
|
||||
{
|
||||
if (chain->head == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&(queue->lc_pair.lock));
|
||||
if (queue->head == NULL)
|
||||
{
|
||||
queue->head = chain->head;
|
||||
*notify = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
queue->tail->next = chain->head;
|
||||
*notify = false;
|
||||
}
|
||||
queue->tail = chain->tail;
|
||||
pthread_mutex_unlock(&(queue->lc_pair.lock));
|
||||
}
|
||||
|
||||
void common_blocked_queue_return_nodes(struct common_blocked_queue *queue,
|
||||
struct common_blocked_node *node)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,6 +31,12 @@ struct common_blocked_node
|
|||
struct common_blocked_node *next;
|
||||
};
|
||||
|
||||
struct common_blocked_chain
|
||||
{
|
||||
struct common_blocked_node *head;
|
||||
struct common_blocked_node *tail;
|
||||
};
|
||||
|
||||
struct common_blocked_queue
|
||||
{
|
||||
struct common_blocked_node *head;
|
||||
|
|
@ -88,6 +94,34 @@ static inline int common_blocked_queue_push(struct common_blocked_queue
|
|||
return result;
|
||||
}
|
||||
|
||||
static inline struct common_blocked_node *common_blocked_queue_alloc_node(
|
||||
struct common_blocked_queue *queue)
|
||||
{
|
||||
return fast_mblock_alloc_object(&queue->mblock);
|
||||
}
|
||||
|
||||
static inline void common_blocked_queue_free_node(
|
||||
struct common_blocked_queue *queue,
|
||||
struct common_blocked_node *node)
|
||||
{
|
||||
fast_mblock_free_object(&queue->mblock, node);
|
||||
}
|
||||
|
||||
void common_blocked_queue_push_chain_ex(struct common_blocked_queue *queue,
|
||||
struct common_blocked_chain *chain, bool *notify);
|
||||
|
||||
static inline void common_blocked_queue_push_chain(
|
||||
struct common_blocked_queue *queue,
|
||||
struct common_blocked_chain *chain)
|
||||
{
|
||||
bool notify;
|
||||
|
||||
common_blocked_queue_push_chain_ex(queue, chain, ¬ify);
|
||||
if (notify)
|
||||
{
|
||||
pthread_cond_signal(&(queue->lc_pair.cond));
|
||||
}
|
||||
}
|
||||
|
||||
void common_blocked_queue_return_nodes(struct common_blocked_queue *queue,
|
||||
struct common_blocked_node *node);
|
||||
|
|
|
|||
Loading…
Reference in New Issue