\hypertarget{a00671_source}{}\doxysection{AAX\+\_\+\+CAtomic\+Queue.\+h}
\label{a00671_source}\index{AAX\_CAtomicQueue.h@{AAX\_CAtomicQueue.h}}
\mbox{\hyperlink{a00671}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *\ \ Copyright\ 2015,\ 2023\ Avid\ Technology,\ Inc.}}
\DoxyCodeLine{00004\ \textcolor{comment}{\ *\ \ All\ rights\ reserved.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *\ \ }}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ \ CONFIDENTIAL:\ this\ document\ contains\ confidential\ information\ of\ Avid.\ Do}}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ \ not\ disclose\ to\ any\ third\ party.\ Use\ of\ the\ information\ contained\ in\ this}}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ \ document\ is\ subject\ to\ an\ Avid\ SDK\ license.}}
\DoxyCodeLine{00009\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00010\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00011\ }
\DoxyCodeLine{00018\ \textcolor{comment}{/*================================================================================================*/}}
\DoxyCodeLine{00020\ \textcolor{preprocessor}{\#ifndef\ AAX\_CATOMICQUEUE\_H}}
\DoxyCodeLine{00021\ \textcolor{preprocessor}{\#define\ AAX\_CATOMICQUEUE\_H}}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00025\ \textcolor{comment}{//\ AAX\ Includes}}
\DoxyCodeLine{00026\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00482}{AAX\_IPointerQueue.h}}"{}}}
\DoxyCodeLine{00027\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00737}{AAX\_Atomic.h}}"{}}}
\DoxyCodeLine{00028\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{a00440}{AAX\_CMutex.h}}"{}}}
\DoxyCodeLine{00029\ }
\DoxyCodeLine{00030\ \textcolor{comment}{//\ Standard\ Includes}}
\DoxyCodeLine{00031\ \textcolor{preprocessor}{\#include\ <cstring>}}
\DoxyCodeLine{00032\ }
\DoxyCodeLine{00033\ }
\DoxyCodeLine{00051\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{size\_t}\ S>}
\DoxyCodeLine{00052\ \textcolor{keyword}{class\ }\mbox{\hyperlink{a01797}{AAX\_CAtomicQueue}}\ :\ \textcolor{keyword}{public}\ \mbox{\hyperlink{a02281}{AAX\_IPointerQueue}}<T>}
\DoxyCodeLine{00053\ \{}
\DoxyCodeLine{00054\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00055\ \ \ \ \ \textcolor{keyword}{virtual}\ \mbox{\hyperlink{a01797_a838ca2b3763f10c4e4d9e72b676fd358}{\string~AAX\_CAtomicQueue}}()\ \{\}}
\DoxyCodeLine{00056\ \ \ \ \ \mbox{\hyperlink{a01797_ae048321b8d75f9fa073e6a24088d8260}{AAX\_CAtomicQueue}}();}
\DoxyCodeLine{00057\ \ \ \ \ }
\DoxyCodeLine{00058\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00059\ \ \ \ \ \textcolor{keyword}{static}\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{size\_t}\ \mbox{\hyperlink{a01797_a7040410a6baeae48d153ef44ee0df1f1}{template\_size}}\ =\ S;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00060\ \ \ \ \ }
\DoxyCodeLine{00061\ \ \ \ \ \textcolor{keyword}{typedef}\ \textcolor{keyword}{typename}\ \mbox{\hyperlink{a02281_ae37a600f078ca0ee6f24b9f45aadc254}{AAX\_IPointerQueue<T>::template\_type}}\ \mbox{\hyperlink{a01797_aae36349d9419de62ce8e74b397749c27}{template\_type}};\ \ }
\DoxyCodeLine{00062\ \ \ \ \ \textcolor{keyword}{typedef}\ \textcolor{keyword}{typename}\ \mbox{\hyperlink{a02281_a2d28a2dffe8dc2b7fe218c41b46734e9}{AAX\_IPointerQueue<T>::value\_type}}\ \mbox{\hyperlink{a01797_acbb95bad3be34c7e4c770bc8c455c252}{value\_type}};\ \ \ \ \ \ \ \ }
\DoxyCodeLine{00063\ \ \ \ \ }
\DoxyCodeLine{00064\ \textcolor{keyword}{public}:\ \textcolor{comment}{//\ AAX\_IContainer}}
\DoxyCodeLine{00065\ \ \ \ \ \textcolor{keyword}{virtual}\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a01797_a9819ff531e285f2acd2c9fd2351617c4}{Clear}}();\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00066\ \ \ \ \ }
\DoxyCodeLine{00067\ \textcolor{keyword}{public}:\ \textcolor{comment}{//\ AAX\_IPointerQueue}}
\DoxyCodeLine{00068\ \ \ \ \ \textcolor{keyword}{virtual}\ \mbox{\hyperlink{a02197_aea020100f0b06636ce7cb25c2fdb0af7}{AAX\_IContainer::EStatus}}\ \mbox{\hyperlink{a01797_a2304d6ba1f1026b6a42de48056ab3050}{Push}}(\mbox{\hyperlink{a01797_acbb95bad3be34c7e4c770bc8c455c252}{value\_type}}\ inElem);\ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00069\ \ \ \ \ \textcolor{keyword}{virtual}\ \mbox{\hyperlink{a01797_acbb95bad3be34c7e4c770bc8c455c252}{value\_type}}\ \mbox{\hyperlink{a01797_a0c64180813c16b4952761f82e32d7edd}{Pop}}();\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00070\ \ \ \ \ \textcolor{keyword}{virtual}\ \mbox{\hyperlink{a01797_acbb95bad3be34c7e4c770bc8c455c252}{value\_type}}\ \mbox{\hyperlink{a01797_a0b732544b0bcdd59acfca7fac5dca984}{Peek}}()\ \textcolor{keyword}{const};\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00071\ \ \ \ \ }
\DoxyCodeLine{00072\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00073\ \ \ \ \ \mbox{\hyperlink{a01857}{AAX\_CMutex}}\ mMutex;}
\DoxyCodeLine{00074\ \ \ \ \ uint32\_t\ mReadIdx;}
\DoxyCodeLine{00075\ \ \ \ \ uint32\_t\ mWriteIdx;}
\DoxyCodeLine{00076\ \ \ \ \ \mbox{\hyperlink{a01797_acbb95bad3be34c7e4c770bc8c455c252}{value\_type}}\ mRingBuffer[S];}
\DoxyCodeLine{00077\ \};}
\DoxyCodeLine{00078\ }
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00081\ }
\DoxyCodeLine{00082\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{size\_t}\ S>}
\DoxyCodeLine{00083\ \textcolor{keyword}{inline}\ \mbox{\hyperlink{a01797_ae048321b8d75f9fa073e6a24088d8260}{AAX\_CAtomicQueue<T,\ S>::AAX\_CAtomicQueue}}()}
\DoxyCodeLine{00084\ :\ \mbox{\hyperlink{a02281}{AAX\_IPointerQueue}}<T>()}
\DoxyCodeLine{00085\ ,\ mMutex()}
\DoxyCodeLine{00086\ ,\ mReadIdx(0)}
\DoxyCodeLine{00087\ ,\ mWriteIdx(0)}
\DoxyCodeLine{00088\ \{}
\DoxyCodeLine{00089\ \ \ \ \ \mbox{\hyperlink{a01797_a9819ff531e285f2acd2c9fd2351617c4}{Clear}}();}
\DoxyCodeLine{00090\ \}}
\DoxyCodeLine{00091\ }
\DoxyCodeLine{00092\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{size\_t}\ S>}
\DoxyCodeLine{00093\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{a01797_a9819ff531e285f2acd2c9fd2351617c4}{AAX\_CAtomicQueue<T,\ S>::Clear}}()}
\DoxyCodeLine{00094\ \{}
\DoxyCodeLine{00095\ \ \ \ \ std::memset((\textcolor{keywordtype}{void}*)mRingBuffer,\ 0x0,\ \textcolor{keyword}{sizeof}(mRingBuffer));}
\DoxyCodeLine{00096\ \}}
\DoxyCodeLine{00097\ }
\DoxyCodeLine{00098\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{size\_t}\ S>}
\DoxyCodeLine{00099\ \textcolor{keyword}{inline}\ \mbox{\hyperlink{a02197_aea020100f0b06636ce7cb25c2fdb0af7}{AAX\_IContainer::EStatus}}\ \mbox{\hyperlink{a01797_a2304d6ba1f1026b6a42de48056ab3050}{AAX\_CAtomicQueue<T,\ S>::Push}}(\textcolor{keyword}{typename}\ \mbox{\hyperlink{a01797_acbb95bad3be34c7e4c770bc8c455c252}{AAX\_CAtomicQueue<T,\ S>::value\_type}}\ inElem)}
\DoxyCodeLine{00100\ \{}
\DoxyCodeLine{00101\ \ \ \ \ \textcolor{keywordflow}{if}\ (NULL\ ==\ inElem)}
\DoxyCodeLine{00102\ \ \ \ \ \{}
\DoxyCodeLine{00103\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a02197_aea020100f0b06636ce7cb25c2fdb0af7a1585c38bb587c4adcadefbe3823ee9f8}{AAX\_IContainer::eStatus\_Unsupported}};}
\DoxyCodeLine{00104\ \ \ \ \ \}}
\DoxyCodeLine{00105\ \ \ \ \ }
\DoxyCodeLine{00106\ \ \ \ \ \mbox{\hyperlink{a02197_aea020100f0b06636ce7cb25c2fdb0af7}{AAX\_IContainer::EStatus}}\ result\ =\ \mbox{\hyperlink{a02197_aea020100f0b06636ce7cb25c2fdb0af7a7586eb60b4cb29ee8ed06aa7c539fe62}{AAX\_IContainer::eStatus\_Unavailable}};}
\DoxyCodeLine{00107\ \ \ \ \ }
\DoxyCodeLine{00108\ \ \ \ \ \mbox{\hyperlink{a01861}{AAX\_StLock\_Guard}}\ guard(mMutex);}
\DoxyCodeLine{00109\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00110\ \ \ \ \ \textcolor{comment}{//\ Possible\ failure\ case\ without\ mutex\ is\ because\ of\ several\ write\ threads\ try\ to\ modify}}
\DoxyCodeLine{00111\ \ \ \ \ \textcolor{comment}{//\ mWriteIdx\ concurrently}}
\DoxyCodeLine{00112\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00113\ \ \ \ \ \textcolor{comment}{//\ Example:}}
\DoxyCodeLine{00114\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00115\ \ \ \ \ \textcolor{comment}{//\ -\/}}
\DoxyCodeLine{00116\ \ \ \ \ \textcolor{comment}{//\ Notation:}}
\DoxyCodeLine{00117\ \ \ \ \ \textcolor{comment}{//\ First\ number\ \ -\/\ write\ thread\ number}}
\DoxyCodeLine{00118\ \ \ \ \ \textcolor{comment}{//\ Second\ number\ -\/\ value\ number}}
\DoxyCodeLine{00119\ \ \ \ \ \textcolor{comment}{//\ 1/15\ -\/\ 1st\ thread\ that\ write\ number\ 15}}
\DoxyCodeLine{00120\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00121\ \ \ \ \ \textcolor{comment}{//\ -\/}}
\DoxyCodeLine{00122\ \ \ \ \ \textcolor{comment}{//\ Queue\ may\ look\ like\ this:}}
\DoxyCodeLine{00123\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ mReadIdx}}
\DoxyCodeLine{00124\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00125\ \ \ \ \ \textcolor{comment}{//\ |.....\ |\ 4/3\ |\ 4/4\ |\ 1/4\ |\ 1/5\ |\ 2/7\ |\ 2/8\ |\ 2/9\ |\ .....|}}
\DoxyCodeLine{00126\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00127\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ mWriteIdx}}
\DoxyCodeLine{00128\ \ \ \ \ \textcolor{comment}{//\ place\#\ |\ \ 0\ \ |\ \ 1\ \ |\ \ 2\ \ |\ \ 3\ \ |\ \ 4\ \ |\ \ 5\ \ |\ \ 6\ \ |\ .....|}}
\DoxyCodeLine{00129\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00130\ \ \ \ \ \textcolor{comment}{//\ -\/}}
\DoxyCodeLine{00131\ \ \ \ \ \textcolor{comment}{//\ Possible\ operation\ order\ (w\ stands\ for\ mWriteIdx,\ r\ -\/\ for\ mReadIdx):}}
\DoxyCodeLine{00132\ \ \ \ \ \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{00133\ \ \ \ \ \textcolor{comment}{//\ thread\#|\ action\ |\ write\ index\ value\ |\ mWriteIdx\ \ \ \ \ \ \ |}}
\DoxyCodeLine{00134\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ |\ internal\ variable\ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00135\ \ \ \ \ \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{00136\ \ \ \ \ \textcolor{comment}{//\ \ \ \ 5\ \ \ |\ \ \ w++\ \ |\ \ \ \ \ \ \ \ 2\ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ 2\ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00137\ \ \ \ \ \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{00138\ \ \ \ \ \textcolor{comment}{//\ \ \ \ 6\ \ \ |\ \ \ w++\ \ |\ \ \ \ \ \ \ \ 3\ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ 3\ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00139\ \ \ \ \ \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{00140\ \ \ \ \ \textcolor{comment}{//\ \ \ \ 5\ \ \ |\ \ false\ |\ \ \ \ \ \ \ \ -\/\ \ \ \ \ \ \ \ \ \ |\ 2not=3\ =>\ 2-\/-\/=1\ |}}
\DoxyCodeLine{00141\ \ \ \ \ \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{00142\ \ \ \ \ \textcolor{comment}{//\ \ read\ \ |\ \ \ r++\ \ |\ \ \ \ \ \ \ \ -\/\ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ -\/\ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00143\ \ \ \ \ \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{00144\ \ \ \ \ \textcolor{comment}{//\ \ read\ \ |\ \ \ r++\ \ |\ \ \ \ \ \ \ \ -\/\ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ -\/\ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00145\ \ \ \ \ \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{00146\ \ \ \ \ \textcolor{comment}{//\ -\/}}
\DoxyCodeLine{00147\ \ \ \ \ \textcolor{comment}{//\ Queue\ state:}}
\DoxyCodeLine{00148\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mReadIdx}}
\DoxyCodeLine{00149\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00150\ \ \ \ \ \textcolor{comment}{//\ |.....\ |\ 4/3\ |\ \ 0\ \ |\ \ 0\ \ |\ 1/5\ |\ 2/7\ |\ 2/8\ |\ 2/9\ |\ .....|}}
\DoxyCodeLine{00151\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00152\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ mWriteIdx}}
\DoxyCodeLine{00153\ \ \ \ \ \textcolor{comment}{//\ place\#\ |\ \ 0\ \ |\ \ 1\ \ |\ \ 2\ \ |\ \ 3\ \ |\ \ 4\ \ |\ \ 5\ \ |\ \ 6\ \ |\ .....|}}
\DoxyCodeLine{00154\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00155\ \ \ \ \ \textcolor{comment}{//\ -\/}}
\DoxyCodeLine{00156\ \ \ \ \ \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{00157\ \ \ \ \ \textcolor{comment}{//\ \ \ \ 6\ \ \ |\ false\ \ |\ \ \ \ \ \ \ \ -\/\ \ \ \ \ \ \ \ \ \ |\ 3not=1\ =>\ 3-\/-\/=2\ |\ //\ place\ 3\ is\ still\ not\ empty\ to\ write}}
\DoxyCodeLine{00158\ \ \ \ \ \textcolor{comment}{//-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{00159\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00160\ \ \ \ \ \textcolor{comment}{//\ -\/}}
\DoxyCodeLine{00161\ \ \ \ \ \textcolor{comment}{//\ Now,\ some\ other\ thread\ (5,\ for\ example)\ can\ successfully\ write}}
\DoxyCodeLine{00162\ \ \ \ \ \textcolor{comment}{//\ it's\ value\ to\ queue\ and\ move\ mWriteIdx\ forward:}}
\DoxyCodeLine{00163\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00164\ \ \ \ \ \textcolor{comment}{//\ -\/}}
\DoxyCodeLine{00165\ \ \ \ \ \textcolor{comment}{//\ Queue\ state:}}
\DoxyCodeLine{00166\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mReadIdx}}
\DoxyCodeLine{00167\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00168\ \ \ \ \ \textcolor{comment}{//\ |.....\ |\ 4/3\ |\ \ 0\ \ |\ 5/1\ |\ 1/5\ |\ 2/7\ |\ 2/8\ |\ 2/9\ |\ .....|}}
\DoxyCodeLine{00169\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00170\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mWriteIdx}}
\DoxyCodeLine{00171\ \ \ \ \ \textcolor{comment}{//\ place\#\ |\ \ 0\ \ |\ \ 1\ \ |\ \ 2\ \ |\ \ 3\ \ |\ \ 4\ \ |\ \ 5\ \ |\ \ 6\ \ |\ .....|}}
\DoxyCodeLine{00172\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00173\ \ \ \ \ \textcolor{comment}{//\ -\/}}
\DoxyCodeLine{00174\ \ \ \ \ \textcolor{comment}{//\ Thus,\ we\ have\ one\ place\ with\ NULL\ value\ left.\ In\ the\ next\ round\ mReadIdx\ will}}
\DoxyCodeLine{00175\ \ \ \ \ \textcolor{comment}{//\ stuck\ on\ place\ \#1\ (queue\ thinks\ that\ it's\ empty)\ until\ one\ of\ the\ write\ threads}}
\DoxyCodeLine{00176\ \ \ \ \ \textcolor{comment}{//\ will\ write\ the\ value\ into\ place\ \#1.\ It\ could\ be\ thread\ \#5,\ so\ we\ have:}}
\DoxyCodeLine{00177\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00178\ \ \ \ \ \textcolor{comment}{//\ -\/}}
\DoxyCodeLine{00179\ \ \ \ \ \textcolor{comment}{//\ Queue\ state:}}
\DoxyCodeLine{00180\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ mReadIdx}}
\DoxyCodeLine{00181\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00182\ \ \ \ \ \textcolor{comment}{//\ |.....\ |\ 9/1\ |\ 5/9\ |\ 5/1\ |\ 1/5\ |\ 2/7\ |\ 2/8\ |\ 2/9\ |\ .....|}}
\DoxyCodeLine{00183\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |}}
\DoxyCodeLine{00184\ \ \ \ \ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ mWriteIdx}}
\DoxyCodeLine{00185\ \ \ \ \ \textcolor{comment}{//\ place\#\ |\ \ 0\ \ |\ \ 1\ \ |\ \ 2\ \ |\ \ 3\ \ |\ \ 4\ \ |\ \ 5\ \ |\ \ 6\ \ |\ .....|}}
\DoxyCodeLine{00186\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00187\ \ \ \ \ \textcolor{comment}{//\ -\/}}
\DoxyCodeLine{00188\ \ \ \ \ \textcolor{comment}{//\ And\ we\ will\ read\ 5/9\ before\ 5/1}}
\DoxyCodeLine{00189\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00190\ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00191\ \ \ \ \ \textcolor{comment}{//\ Note\ that\ read/write\ both\ begin\ at\ index\ 1}}
\DoxyCodeLine{00192\ \ \ \ \ \textcolor{keyword}{const}\ uint32\_t\ idx\ =\ \mbox{\hyperlink{a00737_a56633d7039fae1d31c8984f9baafa17e}{AAX\_Atomic\_IncThenGet\_32}}(mWriteIdx);}
\DoxyCodeLine{00193\ \ \ \ \ \textcolor{keyword}{const}\ uint32\_t\ widx\ =\ idx\ \%\ S;}
\DoxyCodeLine{00194\ \ \ \ \ }
\DoxyCodeLine{00195\ \ \ \ \ \textcolor{comment}{//\ Do\ the\ push.\ If\ the\ value\ at\ the\ current\ write\ index\ is\ non-\/NULL\ then\ we\ have\ filled\ the\ buffer.}}
\DoxyCodeLine{00196\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{bool}\ cxResult\ =\ \mbox{\hyperlink{a00737_ab1c7611e7c95fd61900b8e5a44c36e63}{AAX\_Atomic\_CompareAndExchange\_Pointer}}(mRingBuffer[widx],\ (value\_type)0x0,\ inElem);}
\DoxyCodeLine{00197\ \ \ \ \ }
\DoxyCodeLine{00198\ \ \ \ \ \textcolor{keywordflow}{if}\ (\textcolor{keyword}{false}\ ==\ cxResult)}
\DoxyCodeLine{00199\ \ \ \ \ \{}
\DoxyCodeLine{00200\ \ \ \ \ \ \ \ \ result\ =\ \mbox{\hyperlink{a02197_aea020100f0b06636ce7cb25c2fdb0af7a977319edf1a7a788eeee29dd71982f66}{AAX\_IContainer::eStatus\_Overflow}};}
\DoxyCodeLine{00201\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00202\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ uint32\_t\ ridx\ =\ (0\ ==\ idx)\ ?\ S\ :\ idx-\/1;}
\DoxyCodeLine{00203\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00204\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Note\ the\ write\ index\ has\ already\ been\ incremented,\ so\ in\ the\ event\ of\ an\ overflow\ we\ must}}
\DoxyCodeLine{00205\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ return\ the\ write\ index\ to\ its\ previous\ location.}}
\DoxyCodeLine{00206\ \ \ \ \ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00207\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Note:\ if\ multiple\ write\ threads\ encounter\ concurrent\ push\ overflows\ then\ the\ write\ pointer}}
\DoxyCodeLine{00208\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ will\ not\ be\ fully\ decremented\ back\ to\ the\ overflow\ location,\ and\ the\ read\ index\ will\ need}}
\DoxyCodeLine{00209\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ to\ increment\ multiple\ positions\ to\ clear\ the\ overflow\ state.}}
\DoxyCodeLine{00210\ \textcolor{comment}{//\ \ \ \ \ \ const\ bool\ resetResult\ =\ AAX\_Atomic\_CompareAndExchange\_32(mWriteIdx,\ idx,\ ridx);}}
\DoxyCodeLine{00211\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{a00737_a74a2bdb895976193bdfe4cd2fe31e21e}{AAX\_Atomic\_CompareAndExchange\_32}}(mWriteIdx,\ idx,\ ridx);}
\DoxyCodeLine{00212\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00213\ \textcolor{comment}{//\ \ \ \ \ \ printf("{}AAX\_CAtomicQueue:\ overflow\ -\/\ reset:\ \%s,\ idx:\ \%lu,\ widx:\ \%lu,\ inElem:\ \%p\(\backslash\)n"{},}}
\DoxyCodeLine{00214\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ resetResult\ ?\ "{}yes"{}\ :\ "{}\ no"{},}}
\DoxyCodeLine{00215\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ (unsigned\ long)idx,}}
\DoxyCodeLine{00216\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ (unsigned\ long)widx,}}
\DoxyCodeLine{00217\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ inElem);}}
\DoxyCodeLine{00218\ \ \ \ \ \}}
\DoxyCodeLine{00219\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00220\ \ \ \ \ \{}
\DoxyCodeLine{00221\ \ \ \ \ \ \ \ \ result\ =\ \mbox{\hyperlink{a02197_aea020100f0b06636ce7cb25c2fdb0af7add595169a28f04ed79be4f1c5974eb48}{AAX\_IContainer::eStatus\_Success}};}
\DoxyCodeLine{00222\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00223\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Handle\ wraparound}}
\DoxyCodeLine{00224\ \ \ \ \ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00225\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ There\ may\ be\ multiple\ write\ threads\ pushing\ elements\ at\ the\ same\ time,\ so\ we\ use}}
\DoxyCodeLine{00226\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ (wrapped\ index\ <\ raw\ index)\ instead\ of\ (raw\ index\ ==\ boundary)}}
\DoxyCodeLine{00227\ \ \ \ \ \ \ \ \ \textcolor{comment}{//}}
\DoxyCodeLine{00228\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ This\ assumes\ overhead\ between\ S\ and\ UINT\_32\_MAX\ of\ at\ least\ as\ many\ elements\ as}}
\DoxyCodeLine{00229\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ there\ are\ write\ threads.}}
\DoxyCodeLine{00230\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00231\ \textcolor{comment}{//\ \ \ \ \ \ bool\ exchResult\ =\ false;}}
\DoxyCodeLine{00232\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (widx\ <\ idx)}
\DoxyCodeLine{00233\ \ \ \ \ \ \ \ \ \{}
\DoxyCodeLine{00234\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ exchResult\ =}}
\DoxyCodeLine{00235\ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{a00737_a74a2bdb895976193bdfe4cd2fe31e21e}{AAX\_Atomic\_CompareAndExchange\_32}}(mWriteIdx,\ idx,\ widx);}
\DoxyCodeLine{00236\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00237\ \ \ \ \ \ \ \ \ }
\DoxyCodeLine{00238\ \textcolor{comment}{//\ \ \ \ \ \ printf("{}AAX\_CAtomicQueue:\ pushed\ \ \ \ -\/\ reset:\ \%s,\ idx:\ \%lu,\ widx:\ \%lu,\ inElem:\ \%p\(\backslash\)n"{},}}
\DoxyCodeLine{00239\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ (widx\ <\ idx)\ ?\ exchResult\ ?\ "{}yes"{}\ :\ "{}\ no"{}\ :\ "{}n/a"{},}}
\DoxyCodeLine{00240\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ (unsigned\ long)idx,}}
\DoxyCodeLine{00241\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ (unsigned\ long)widx,}}
\DoxyCodeLine{00242\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ inElem);}}
\DoxyCodeLine{00243\ \ \ \ \ \}}
\DoxyCodeLine{00244\ \ \ \ \ }
\DoxyCodeLine{00245\ \ \ \ \ \textcolor{keywordflow}{return}\ result;}
\DoxyCodeLine{00246\ \}}
\DoxyCodeLine{00247\ }
\DoxyCodeLine{00248\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{size\_t}\ S>}
\DoxyCodeLine{00249\ \textcolor{keyword}{inline}\ \textcolor{keyword}{typename}\ \mbox{\hyperlink{a01797_acbb95bad3be34c7e4c770bc8c455c252}{AAX\_CAtomicQueue<T,\ S>::value\_type}}\ \mbox{\hyperlink{a01797_a0c64180813c16b4952761f82e32d7edd}{AAX\_CAtomicQueue<T,\ S>::Pop}}()}
\DoxyCodeLine{00250\ \{}
\DoxyCodeLine{00251\ \ \ \ \ \textcolor{comment}{//\ Note\ that\ read/write\ both\ begin\ at\ index\ 1}}
\DoxyCodeLine{00252\ \ \ \ \ mReadIdx\ =\ (mReadIdx+1)\ \%\ template\_size;}
\DoxyCodeLine{00253\ \ \ \ \ value\_type\ \textcolor{keyword}{const}\ val\ =\ \mbox{\hyperlink{a00737_add2856260ffb4309c4e515bac8490bea}{AAX\_Atomic\_Exchange\_Pointer}}(mRingBuffer[mReadIdx],\ (value\_type)0x0);}
\DoxyCodeLine{00254\ \ \ \ \ }
\DoxyCodeLine{00255\ \textcolor{comment}{//\ \ printf("{}AAX\_CAtomicQueue:\ popped\ \ \ \ -\/\ reset:\ \%s,\ idx:\ \%lu,\ \ \ \ \ \ \ \ \ \ \ \ val:\ \ \ \ \%p\(\backslash\)n"{},}}
\DoxyCodeLine{00256\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ (0x0\ ==\ val)\ ?\ "{}yes"{}\ :\ "{}\ no"{},}}
\DoxyCodeLine{00257\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ (unsigned\ long)mReadIdx,}}
\DoxyCodeLine{00258\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ val);}}
\DoxyCodeLine{00259\ \ \ \ \ }
\DoxyCodeLine{00260\ \ \ \ \ \textcolor{keywordflow}{if}\ (0x0\ ==\ val)}
\DoxyCodeLine{00261\ \ \ \ \ \{}
\DoxyCodeLine{00262\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ If\ the\ value\ is\ NULL\ then\ no\ value\ has\ yet\ been\ written\ to\ this\ location.\ Decrement\ the\ read\ index}}
\DoxyCodeLine{00263\ \ \ \ \ \ \ \ \ -\/-\/mReadIdx;\ \textcolor{comment}{//\ No\ need\ to\ handle\ wraparound\ since\ the\ read\ index\ will\ be\ incremented\ before\ the\ next\ read}}
\DoxyCodeLine{00264\ \ \ \ \ \}}
\DoxyCodeLine{00265\ \ \ \ \ }
\DoxyCodeLine{00266\ \ \ \ \ \textcolor{keywordflow}{return}\ val;}
\DoxyCodeLine{00267\ \}}
\DoxyCodeLine{00268\ }
\DoxyCodeLine{00269\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{size\_t}\ S>}
\DoxyCodeLine{00270\ \textcolor{keyword}{inline}\ \textcolor{keyword}{typename}\ \mbox{\hyperlink{a01797_acbb95bad3be34c7e4c770bc8c455c252}{AAX\_CAtomicQueue<T,\ S>::value\_type}}\ \mbox{\hyperlink{a01797_a0b732544b0bcdd59acfca7fac5dca984}{AAX\_CAtomicQueue<T,\ S>::Peek}}()\textcolor{keyword}{\ const}}
\DoxyCodeLine{00271\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00272\ \ \ \ \ \textcolor{comment}{//\ I\ don't\ think\ that\ we\ need\ a\ memory\ barrier\ here\ because:}}
\DoxyCodeLine{00273\ \ \ \ \ \textcolor{comment}{//\ a)\ mReadIdx\ will\ only\ be\ modified\ from\ the\ read\ thread,\ and\ therefore\ presumably}}
\DoxyCodeLine{00274\ \ \ \ \ \textcolor{comment}{//\ \ \ \ using\ the\ same\ CPU\ (or\ at\ least\ I\ can't\ see\ any\ way\ for\ mReadIndex\ modification}}
\DoxyCodeLine{00275\ \ \ \ \ \textcolor{comment}{//\ \ \ \ ordering\ to\ be\ a\ problem\ between\ Peek()\ and\ Pop()\ on\ a\ single\ thread.)}}
\DoxyCodeLine{00276\ \ \ \ \ \textcolor{comment}{//\ b)\ We\ don't\ care\ if\ mRingBuffer\ modifications\ are\ run\ out\ of\ order\ between\ the\ read}}
\DoxyCodeLine{00277\ \ \ \ \ \textcolor{comment}{//\ \ \ \ and\ write\ threads,\ as\ long\ as\ they\ are\ "{}close"{}.}}
\DoxyCodeLine{00278\ \ \ \ \ \textcolor{keyword}{const}\ uint32\_t\ testIdx\ =\ (mReadIdx+1)\ \%\ template\_size;}
\DoxyCodeLine{00279\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{a00737_ace950fb6e426fd95d69da49462dfb878}{AAX\_Atomic\_Load\_Pointer}}(\&mRingBuffer[testIdx]);}
\DoxyCodeLine{00280\ \}}
\DoxyCodeLine{00281\ }
\DoxyCodeLine{00282\ \textcolor{comment}{//\ Attempt\ to\ support\ multiple\ read\ threads}}
\DoxyCodeLine{00283\ \textcolor{comment}{//}}
\DoxyCodeLine{00284\ \textcolor{comment}{//\ This\ approach\ is\ broken\ in\ the\ following\ scenario:}}
\DoxyCodeLine{00285\ \textcolor{comment}{//}}
\DoxyCodeLine{00286\ \textcolor{comment}{//\ Thread\ |\ Operation}}
\DoxyCodeLine{00287\ \textcolor{comment}{//\ \ \ \ \ \ A\ \ \ Pop\ v\ enter}}
\DoxyCodeLine{00288\ \textcolor{comment}{//\ \ \ \ \ \ A\ \ \ Pop\ -\/\ increment/get\ read\ index\ (get\ 1)}}
\DoxyCodeLine{00289\ \textcolor{comment}{//\ \ \ \ \ \ A\ \ \ Pop\ -\/\ exchange\ pointer\ (get\ 0x0)}}
\DoxyCodeLine{00290\ \textcolor{comment}{//\ \ other\ \ \ Push\ ptr1}}
\DoxyCodeLine{00291\ \textcolor{comment}{//\ \ other\ \ \ Push\ ptr2}}
\DoxyCodeLine{00292\ \textcolor{comment}{//\ \ \ \ \ \ B\ \ \ Pop\ v\ enter}}
\DoxyCodeLine{00293\ \textcolor{comment}{//\ \ \ \ \ \ B\ \ \ Pop\ -\/\ increment/get\ read\ index\ (get\ 2)}}
\DoxyCodeLine{00294\ \textcolor{comment}{//\ \ \ \ \ \ B\ \ \ Pop\ -\/\ exchange\ pointer\ (get\ ptr2)}}
\DoxyCodeLine{00295\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ ERROR:\ popped\ ptr2\ before\ ptr1}}
\DoxyCodeLine{00296\ \textcolor{comment}{//\ \ \ \ \ \ B\ \ \ Pop\ \string^\ exit}}
\DoxyCodeLine{00297\ \textcolor{comment}{//\ \ \ \ \ \ A\ \ \ Pop\ -\/\ decrement\ read\ index\ (set\ 1)}}
\DoxyCodeLine{00298\ \textcolor{comment}{//\ \ \ \ \ \ A\ \ \ Pop\ \string^\ exit}}
\DoxyCodeLine{00299\ \textcolor{comment}{//\ \ \ \ any\ \ \ Pop\ v\ enter}}
\DoxyCodeLine{00300\ \textcolor{comment}{//\ \ \ \ any\ \ \ Pop\ -\/\ increment/get\ read\ index\ (get\ 2)}}
\DoxyCodeLine{00301\ \textcolor{comment}{//\ \ \ \ any\ \ \ Pop\ -\/\ exchange\ pointer\ (get\ 0x0)}}
\DoxyCodeLine{00302\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ ERROR:\ should\ be\ ptr2}}
\DoxyCodeLine{00303\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ This\ NULL\ state\ continues\ for\ further\ Pop\ calls\ until\ either\ Push\ wraps\ around}}
\DoxyCodeLine{00304\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ or\ another\ pair\ of\ concurrent\ calls\ to\ Pop\ just\ happens\ to\ re-\/aligign\ the\ read}}
\DoxyCodeLine{00305\ \textcolor{comment}{//\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ index\ by\ incrementing\ twice\ before\ any\ reads\ occur}}
\DoxyCodeLine{00306\ \textcolor{comment}{//\ \ \ \ any\ \ \ Pop\ -\/\ decrement\ read\ index\ (set\ 1)}}
\DoxyCodeLine{00307\ \textcolor{comment}{//\ \ \ \ any\ \ \ Pop\ \string^\ exit}}
\DoxyCodeLine{00308\ \textcolor{comment}{//}}
\DoxyCodeLine{00309\ \textcolor{comment}{//\ This\ could\ be\ fixed\ by\ incrementing\ the\ read\ index\ until\ either\ a\ non-\/NULL\ value\ is\ found\ or}}
\DoxyCodeLine{00310\ \textcolor{comment}{//\ the\ initial\ position\ is\ reached,\ but\ that\ would\ have\ terrible\ performance.}}
\DoxyCodeLine{00311\ \textcolor{comment}{//}}
\DoxyCodeLine{00312\ \textcolor{comment}{//\ In\ any\ case,\ assuming\ a\ single\ read\ thread\ is\ optimal\ when\ we\ want\ maximum\ performance\ for\ read}}
\DoxyCodeLine{00313\ \textcolor{comment}{//\ operations,\ since\ this\ requires\ the\ fewest\ number\ of\ atomic\ operations\ in\ the\ read\ methods}}
\DoxyCodeLine{00314\ \textcolor{comment}{/*}}
\DoxyCodeLine{00315\ \textcolor{comment}{template\ <typename\ T,\ size\_t\ S>}}
\DoxyCodeLine{00316\ \textcolor{comment}{inline\ typename\ AAX\_CAtomicQueue<T,\ S>::value\_type\ AAX\_CAtomicQueue<T,\ S>::Pop()}}
\DoxyCodeLine{00317\ \textcolor{comment}{\{}}
\DoxyCodeLine{00318\ \textcolor{comment}{\ \ \ \ const\ uint32\_t\ idx\ =\ AAX\_Atomic\_IncThenGet\_32(mReadIdx);}}
\DoxyCodeLine{00319\ \textcolor{comment}{\ \ \ \ const\ uint32\_t\ widx\ =\ idx\ \%\ S;}}
\DoxyCodeLine{00320\ \textcolor{comment}{\ \ \ \ }}
\DoxyCodeLine{00321\ \textcolor{comment}{\ \ \ \ value\_type\ const\ val\ =\ AAX\_Atomic\_Exchange\_Pointer(mRingBuffer[widx],\ (value\_type)0x0);}}
\DoxyCodeLine{00322\ \textcolor{comment}{\ \ \ \ }}
\DoxyCodeLine{00323\ \textcolor{comment}{\ \ \ \ if\ (0x0\ ==\ val)}}
\DoxyCodeLine{00324\ \textcolor{comment}{\ \ \ \ \{}}
\DoxyCodeLine{00325\ \textcolor{comment}{\ \ \ \ \ \ \ \ //\ If\ the\ value\ is\ NULL\ then\ no\ value\ has\ yet\ been\ written\ to\ this\ location.\ Decrement\ the\ read\ index}}
\DoxyCodeLine{00326\ \textcolor{comment}{\ \ \ \ \ \ \ \ AAX\_Atomic\_DecThenGet\_32(mReadIdx);}}
\DoxyCodeLine{00327\ \textcolor{comment}{\ \ \ \ \}}}
\DoxyCodeLine{00328\ \textcolor{comment}{\ \ \ \ else}}
\DoxyCodeLine{00329\ \textcolor{comment}{\ \ \ \ \{}}
\DoxyCodeLine{00330\ \textcolor{comment}{\ \ \ \ \ \ \ \ //\ Handle\ wraparound\ (assumes\ some\ overhead\ between\ S\ and\ UINT\_32\_MAX)}}
\DoxyCodeLine{00331\ \textcolor{comment}{\ \ \ \ \ \ \ \ if\ (widx\ <\ idx)}}
\DoxyCodeLine{00332\ \textcolor{comment}{\ \ \ \ \ \ \ \ \{}}
\DoxyCodeLine{00333\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ AAX\_Atomic\_CompareAndExchange\_32(mReadIdx,\ idx,\ widx);}}
\DoxyCodeLine{00334\ \textcolor{comment}{\ \ \ \ \ \ \ \ \}}}
\DoxyCodeLine{00335\ \textcolor{comment}{\ \ \ \ \}}}
\DoxyCodeLine{00336\ \textcolor{comment}{\ \ \ \ }}
\DoxyCodeLine{00337\ \textcolor{comment}{\ \ \ \ return\ val;}}
\DoxyCodeLine{00338\ \textcolor{comment}{\}}}
\DoxyCodeLine{00339\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00340\ }
\DoxyCodeLine{00342\ }
\DoxyCodeLine{00344\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{/*\ defined(AAX\_CATOMICQUEUE\_H)\ */}\textcolor{preprocessor}{}}

\end{DoxyCode}
