add function fc_queue_alloc_chain
parent
1b35cbc094
commit
2432e0bc79
2
HISTORY
2
HISTORY
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Version 1.54 2021-09-13
|
||||
Version 1.54 2021-09-22
|
||||
* fast_allocator.[hc]: correct reclaim_interval logic
|
||||
* shared_func.[hc]: add functions getFileContentEx1 and getFileContent1
|
||||
* fc_queue.[hc]: add function fc_queue_timedpeek
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#include <pthread.h>
|
||||
#include "common_define.h"
|
||||
#include "fc_memory.h"
|
||||
#include "chain.h"
|
||||
#include "logger.h"
|
||||
|
||||
#define FAST_MBLOCK_NAME_SIZE 32
|
||||
|
|
@ -304,6 +303,14 @@ static inline int fast_mblock_free_object(struct fast_mblock_man *mblock,
|
|||
return fast_mblock_free(mblock, fast_mblock_to_node_ptr(object));
|
||||
}
|
||||
|
||||
/**
|
||||
free objects (put objects to the mblock)
|
||||
parameters:
|
||||
mblock: the mblock pointer
|
||||
objs: the object array to free
|
||||
count: the count of the object array
|
||||
return none
|
||||
*/
|
||||
void fast_mblock_free_objects(struct fast_mblock_man *mblock,
|
||||
void **objs, const int count);
|
||||
|
||||
|
|
|
|||
|
|
@ -206,6 +206,26 @@ void *fc_queue_timedpeek(struct fc_queue *queue,
|
|||
return data;
|
||||
}
|
||||
|
||||
int fc_queue_alloc_chain(struct fc_queue *queue, struct fast_mblock_man
|
||||
*mblock, const int count, struct fc_queue_info *chain)
|
||||
{
|
||||
struct fast_mblock_node *node;
|
||||
|
||||
if ((node=fast_mblock_batch_alloc(mblock, count)) == NULL) {
|
||||
chain->head = chain->tail = NULL;
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
chain->head = chain->tail = node->data;
|
||||
while ((node=node->next) != NULL) {
|
||||
FC_QUEUE_NEXT_PTR(queue, chain->tail) = node->data;
|
||||
chain->tail = node->data;
|
||||
}
|
||||
FC_QUEUE_NEXT_PTR(queue, chain->tail) = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fc_queue_free_chain(struct fc_queue *queue, struct fast_mblock_man
|
||||
*mblock, struct fc_queue_info *qinfo)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -173,6 +173,9 @@ void *fc_queue_timedpeek(struct fc_queue *queue,
|
|||
#define fc_queue_timedpeek_us(queue, timeout_us) \
|
||||
fc_queue_timedpeek(queue, timeout_us, FC_TIME_UNIT_USECOND)
|
||||
|
||||
int fc_queue_alloc_chain(struct fc_queue *queue, struct fast_mblock_man
|
||||
*mblock, const int count, struct fc_queue_info *chain);
|
||||
|
||||
int fc_queue_free_chain(struct fc_queue *queue, struct fast_mblock_man
|
||||
*mblock, struct fc_queue_info *qinfo);
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,9 @@ void *sorted_queue_pop_ex(struct sorted_queue *sq,
|
|||
|
||||
PTHREAD_MUTEX_LOCK(&sq->queue.lc_pair.lock);
|
||||
do {
|
||||
if (sq->queue.head == NULL) {
|
||||
if (sq->queue.head == NULL || sq->compare_func(
|
||||
sq->queue.head, less_equal) > 0)
|
||||
{
|
||||
if (!blocked) {
|
||||
data = NULL;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue