urcu: move busy-wait code and name it ___cds_wfq_node_sync_next()
authorLai Jiangshan <laijs@cn.fujitsu.com>
Thu, 9 Aug 2012 14:24:38 +0000 (10:24 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 9 Aug 2012 14:24:38 +0000 (10:24 -0400)
This code which waits for a node's next pointer until it appears, will
be used many times, move it to a help function and name it
___cds_wfq_node_sync_next().

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
urcu/static/wfqueue.h

index 19314f5f9223498ba45b749c4af678ed607cf2fb..636e1afa8e949e19bae448b1d5775eefd202f717 100644 (file)
@@ -84,6 +84,29 @@ static inline void _cds_wfq_enqueue(struct cds_wfq_queue *q,
        CMM_STORE_SHARED(*old_tail, node);
 }
 
+/*
+ * Waiting for enqueuer to complete enqueue and return the next node
+ */
+static inline struct cds_wfq_node *
+___cds_wfq_node_sync_next(struct cds_wfq_node *node)
+{
+       struct cds_wfq_node *next;
+       int attempt = 0;
+
+       /*
+        * Adaptative busy-looping waiting for enqueuer to complete enqueue.
+        */
+       while ((next = CMM_LOAD_SHARED(node->next)) == NULL) {
+               if (++attempt >= WFQ_ADAPT_ATTEMPTS) {
+                       poll(NULL, 0, WFQ_WAIT);        /* Wait for 10ms */
+                       attempt = 0;
+               } else
+                       caa_cpu_relax();
+       }
+
+       return next;
+}
+
 /*
  * It is valid to reuse and free a dequeued node immediately.
  *
@@ -96,7 +119,6 @@ static inline struct cds_wfq_node *
 ___cds_wfq_dequeue_blocking(struct cds_wfq_queue *q)
 {
        struct cds_wfq_node *node, *next;
-       int attempt = 0;
 
        /*
         * Queue is empty if it only contains the dummy node.
@@ -105,16 +127,8 @@ ___cds_wfq_dequeue_blocking(struct cds_wfq_queue *q)
                return NULL;
        node = q->head;
 
-       /*
-        * Adaptative busy-looping waiting for enqueuer to complete enqueue.
-        */
-       while ((next = CMM_LOAD_SHARED(node->next)) == NULL) {
-               if (++attempt >= WFQ_ADAPT_ATTEMPTS) {
-                       poll(NULL, 0, WFQ_WAIT);        /* Wait for 10ms */
-                       attempt = 0;
-               } else
-                       caa_cpu_relax();
-       }
+       next = ___cds_wfq_node_sync_next(node);
+
        /*
         * Move queue head forward.
         */
This page took 0.025564 seconds and 4 git commands to generate.