projects
/
urcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
WF queue cleanup
[urcu.git]
/
urcu
/
wfqueue.h
diff --git
a/urcu/wfqueue.h
b/urcu/wfqueue.h
index b4208dae65f28e0f0564c07dd77f338f72b4862b..2eaace1c260f99e7562a36649fc5129fdb03cce0 100644
(file)
--- a/
urcu/wfqueue.h
+++ b/
urcu/wfqueue.h
@@
-35,6
+35,9
@@
extern "C" {
#error "Dynamic loader LGPL wrappers not implemented yet"
#endif
#error "Dynamic loader LGPL wrappers not implemented yet"
#endif
+#define WFQ_ADAPT_ATTEMPTS 10 /* Retry if being set */
+#define WFQ_WAIT 10 /* Wait 10 ms if being set */
+
/*
* Queue with wait-free enqueue/blocking dequeue.
* This implementation adds a dummy head node when the queue is empty to ensure
/*
* Queue with wait-free enqueue/blocking dequeue.
* This implementation adds a dummy head node when the queue is empty to ensure
@@
-101,7
+104,7
@@
struct wfq_node *
__wfq_dequeue_blocking(struct wfq_queue *q)
{
struct wfq_node *node, *next;
__wfq_dequeue_blocking(struct wfq_queue *q)
{
struct wfq_node *node, *next;
- int
busy_wait = 16
;
+ int
attempt = 0
;
/*
* Queue is empty if it only contains the dummy node.
/*
* Queue is empty if it only contains the dummy node.
@@
-114,11
+117,11
@@
__wfq_dequeue_blocking(struct wfq_queue *q)
* Adaptative busy-looping waiting for enqueuer to complete enqueue.
*/
while ((next = LOAD_SHARED(node->next)) == NULL) {
* Adaptative busy-looping waiting for enqueuer to complete enqueue.
*/
while ((next = LOAD_SHARED(node->next)) == NULL) {
- if (
busy_wait > 0
) {
- cpu_relax();
-
busy_wait--
;
+ if (
++attempt >= WFQ_ADAPT_ATTEMPTS
) {
+ poll(NULL, 0, WFQ_WAIT); /* Wait for 10ms */
+
attempt = 0
;
} else
} else
- poll(NULL, 0, 1); /* Wait for 1ms */
+ cpu_relax();
}
/*
* Move queue head forward.
}
/*
* Move queue head forward.
This page took
0.024816 seconds
and
4
git commands to generate.