X-Git-Url: https://git.lttng.org/?p=urcu.git;a=blobdiff_plain;f=include%2Furcu%2Fstatic%2Fwfcqueue.h;h=5e54cbed3526a7617428f88f9f3e33bbb379fca8;hp=67ac05ffd15e384dc42317e0d5b4d0c93d71c2d6;hb=70469b43316ecc8d6053550504858ad8a8ef9b16;hpb=6893800a4d1cc14dff0395ddcd660a5138db183d diff --git a/include/urcu/static/wfcqueue.h b/include/urcu/static/wfcqueue.h index 67ac05f..5e54cbe 100644 --- a/include/urcu/static/wfcqueue.h +++ b/include/urcu/static/wfcqueue.h @@ -112,7 +112,7 @@ static inline void _cds_wfcq_init(struct cds_wfcq_head *head, * cds_wfcq_init(). */ static inline void _cds_wfcq_destroy(struct cds_wfcq_head *head, - struct cds_wfcq_tail *tail) + struct cds_wfcq_tail *tail __attribute__((unused))) { int ret = pthread_mutex_destroy(&head->lock); assert(!ret); @@ -158,7 +158,7 @@ static inline bool _cds_wfcq_empty(cds_wfcq_head_ptr_t u_head, } static inline void _cds_wfcq_dequeue_lock(struct cds_wfcq_head *head, - struct cds_wfcq_tail *tail) + struct cds_wfcq_tail *tail __attribute__((unused))) { int ret; @@ -167,7 +167,7 @@ static inline void _cds_wfcq_dequeue_lock(struct cds_wfcq_head *head, } static inline void _cds_wfcq_dequeue_unlock(struct cds_wfcq_head *head, - struct cds_wfcq_tail *tail) + struct cds_wfcq_tail *tail __attribute__((unused))) { int ret; @@ -223,6 +223,23 @@ static inline bool _cds_wfcq_enqueue(cds_wfcq_head_ptr_t head, return ___cds_wfcq_append(head, tail, new_tail, new_tail); } +/* + * CDS_WFCQ_WAIT_SLEEP: + * + * By default, this sleeps for the given @msec milliseconds. + * This is a macro which LGPL users may #define themselves before + * including wfcqueue.h to override the default behavior (e.g. + * to log a warning or perform other background work). + */ +#ifndef CDS_WFCQ_WAIT_SLEEP +#define CDS_WFCQ_WAIT_SLEEP(msec) ___cds_wfcq_wait_sleep(msec) +#endif + +static inline void ___cds_wfcq_wait_sleep(int msec) +{ + (void) poll(NULL, 0, msec); +} + /* * ___cds_wfcq_busy_wait: adaptative busy-wait. * @@ -234,7 +251,7 @@ ___cds_wfcq_busy_wait(int *attempt, int blocking) if (!blocking) return 1; if (++(*attempt) >= WFCQ_ADAPT_ATTEMPTS) { - (void) poll(NULL, 0, WFCQ_WAIT); /* Wait for 10ms */ + CDS_WFCQ_WAIT_SLEEP(WFCQ_WAIT); /* Wait for 10ms */ *attempt = 0; } else { caa_cpu_relax(); @@ -314,7 +331,7 @@ ___cds_wfcq_first_nonblocking(cds_wfcq_head_ptr_t head, } static inline struct cds_wfcq_node * -___cds_wfcq_next(cds_wfcq_head_ptr_t head, +___cds_wfcq_next(cds_wfcq_head_ptr_t head __attribute__((unused)), struct cds_wfcq_tail *tail, struct cds_wfcq_node *node, int blocking)