Makefiles: use appropriate preprocessor vs. compiler flags
[model-checker-benchmarks.git] / mpmc-queue / mpmc-queue.h
index bef0f32..918415f 100644 (file)
@@ -7,7 +7,7 @@ struct mpmc_boundq_1_alt
 private:
 
        // elements should generally be cache-line-size padded :
-       nonatomic<t_element>  m_array[t_size];
+       t_element               m_array[t_size];
 
        // rdwr counts the reads & writes that have started
        atomic<unsigned int>    m_rdwr;
@@ -17,13 +17,16 @@ private:
 
 public:
 
-       mpmc_boundq_1_alt() : m_rdwr(0), m_read(0), m_written(0)
+       mpmc_boundq_1_alt()
        {
+               m_rdwr = 0;
+               m_read = 0;
+               m_written = 0;
        }
 
        //-----------------------------------------------------
 
-       nonatomic<t_element> * read_fetch() {
+       t_element * read_fetch() {
                unsigned int rdwr = m_rdwr.load(mo_acquire);
                unsigned int rd,wr;
                for(;;) {
@@ -35,15 +38,17 @@ public:
 
                        if ( m_rdwr.compare_exchange_weak(rdwr,rdwr+(1<<16),mo_acq_rel) )
                                break;
+                       else
+                               thrd_yield();
                }
 
                // (*1)
                rl::backoff bo;
                while ( (m_written.load(mo_acquire) & 0xFFFF) != wr ) {
-                       bo.yield();
+                       thrd_yield();
                }
 
-               nonatomic<t_element> * p = & ( m_array[ rd % t_size ] );
+               t_element * p = & ( m_array[ rd % t_size ] );
 
                return p;
        }
@@ -54,7 +59,7 @@ public:
 
        //-----------------------------------------------------
 
-       nonatomic<t_element> * write_prepare() {
+       t_element * write_prepare() {
                unsigned int rdwr = m_rdwr.load(mo_acquire);
                unsigned int rd,wr;
                for(;;) {
@@ -66,15 +71,17 @@ public:
 
                        if ( m_rdwr.compare_exchange_weak(rdwr,(rd<<16) | ((wr+1)&0xFFFF),mo_acq_rel) )
                                break;
+                       else
+                               thrd_yield();
                }
 
                // (*1)
                rl::backoff bo;
                while ( (m_read.load(mo_acquire) & 0xFFFF) != rd ) {
-                       bo.yield();
+                       thrd_yield();
                }
 
-               nonatomic<t_element> * p = & ( m_array[ wr % t_size ] );
+               t_element * p = & ( m_array[ wr % t_size ] );
 
                return p;
        }