X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=mpmc-queue%2Fmpmc-queue.h;h=47af8eab37b7509ca8e257e118c5b7e38ec8278a;hb=5ab6d890042234648c0baec333ed65e90ca055cf;hp=f73ab992e0b1fcfbbf962b067c204cdb75b9578f;hpb=ca67665a06590d48352fd2c601004a39bd993ca8;p=model-checker-benchmarks.git diff --git a/mpmc-queue/mpmc-queue.h b/mpmc-queue/mpmc-queue.h index f73ab99..47af8ea 100644 --- a/mpmc-queue/mpmc-queue.h +++ b/mpmc-queue/mpmc-queue.h @@ -34,16 +34,18 @@ public: wr = rdwr & 0xFFFF; if ( wr == rd ) // empty - return false; + return NULL; 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(); } t_element * p = & ( m_array[ rd % t_size ] ); @@ -69,12 +71,14 @@ 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(); } t_element * p = & ( m_array[ wr % t_size ] );