add function fc_queue_timedpeek
parent
44dcf4f821
commit
2fafa215fd
3
HISTORY
3
HISTORY
|
|
@ -1,7 +1,8 @@
|
|||
|
||||
Version 1.54 2021-08-08
|
||||
Version 1.54 2021-08-11
|
||||
* fast_allocator.[hc]: correct reclaim_interval logic
|
||||
* shared_func.[hc]: add functions getFileContentEx1 and getFileContent1
|
||||
* fc_queue.[hc]: add function fc_queue_timedpeek
|
||||
|
||||
Version 1.53 2021-06-30
|
||||
* process_action support action status
|
||||
|
|
|
|||
|
|
@ -181,21 +181,35 @@ void *fc_queue_timedpop(struct fc_queue *queue,
|
|||
void *data;
|
||||
|
||||
PTHREAD_MUTEX_LOCK(&queue->lc_pair.lock);
|
||||
do {
|
||||
data = queue->head;
|
||||
if (data == NULL) {
|
||||
fc_cond_timedwait(&queue->lc_pair, timeout, time_unit);
|
||||
data = queue->head;
|
||||
if (data == NULL) {
|
||||
fc_cond_timedwait(&queue->lc_pair, timeout, time_unit);
|
||||
data = queue->head;
|
||||
}
|
||||
}
|
||||
|
||||
if (data != NULL) {
|
||||
queue->head = FC_QUEUE_NEXT_PTR(queue, data);
|
||||
if (queue->head == NULL) {
|
||||
queue->tail = NULL;
|
||||
}
|
||||
if (data != NULL) {
|
||||
queue->head = FC_QUEUE_NEXT_PTR(queue, data);
|
||||
if (queue->head == NULL) {
|
||||
queue->tail = NULL;
|
||||
}
|
||||
} while (0);
|
||||
|
||||
}
|
||||
PTHREAD_MUTEX_UNLOCK(&queue->lc_pair.lock);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void *fc_queue_timedpeek(struct fc_queue *queue,
|
||||
const int timeout, const int time_unit)
|
||||
{
|
||||
void *data;
|
||||
|
||||
PTHREAD_MUTEX_LOCK(&queue->lc_pair.lock);
|
||||
data = queue->head;
|
||||
if (data == NULL) {
|
||||
fc_cond_timedwait(&queue->lc_pair, timeout, time_unit);
|
||||
data = queue->head;
|
||||
}
|
||||
PTHREAD_MUTEX_UNLOCK(&queue->lc_pair.lock);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,6 +160,18 @@ void *fc_queue_timedpop(struct fc_queue *queue,
|
|||
#define fc_queue_timedpop_us(queue, timeout_us) \
|
||||
fc_queue_timedpop(queue, timeout_us, FC_TIME_UNIT_USECOND)
|
||||
|
||||
void *fc_queue_timedpeek(struct fc_queue *queue,
|
||||
const int timeout, const int time_unit);
|
||||
|
||||
#define fc_queue_timedpeek_sec(queue, timeout) \
|
||||
fc_queue_timedpeek(queue, timeout, FC_TIME_UNIT_SECOND)
|
||||
|
||||
#define fc_queue_timedpeek_ms(queue, timeout_ms) \
|
||||
fc_queue_timedpeek(queue, timeout_ms, FC_TIME_UNIT_MSECOND)
|
||||
|
||||
#define fc_queue_timedpeek_us(queue, timeout_us) \
|
||||
fc_queue_timedpeek(queue, timeout_us, FC_TIME_UNIT_USECOND)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue