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
|
* fast_allocator.[hc]: correct reclaim_interval logic
|
||||||
* shared_func.[hc]: add functions getFileContentEx1 and getFileContent1
|
* shared_func.[hc]: add functions getFileContentEx1 and getFileContent1
|
||||||
|
* fc_queue.[hc]: add function fc_queue_timedpeek
|
||||||
|
|
||||||
Version 1.53 2021-06-30
|
Version 1.53 2021-06-30
|
||||||
* process_action support action status
|
* process_action support action status
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,6 @@ void *fc_queue_timedpop(struct fc_queue *queue,
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
PTHREAD_MUTEX_LOCK(&queue->lc_pair.lock);
|
PTHREAD_MUTEX_LOCK(&queue->lc_pair.lock);
|
||||||
do {
|
|
||||||
data = queue->head;
|
data = queue->head;
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
fc_cond_timedwait(&queue->lc_pair, timeout, time_unit);
|
fc_cond_timedwait(&queue->lc_pair, timeout, time_unit);
|
||||||
|
|
@ -194,8 +193,23 @@ void *fc_queue_timedpop(struct fc_queue *queue,
|
||||||
queue->tail = NULL;
|
queue->tail = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (0);
|
|
||||||
|
|
||||||
PTHREAD_MUTEX_UNLOCK(&queue->lc_pair.lock);
|
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;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,18 @@ void *fc_queue_timedpop(struct fc_queue *queue,
|
||||||
#define fc_queue_timedpop_us(queue, timeout_us) \
|
#define fc_queue_timedpop_us(queue, timeout_us) \
|
||||||
fc_queue_timedpop(queue, timeout_us, FC_TIME_UNIT_USECOND)
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue