Mercurial > pub > ImplabNet
diff Implab/Parallels/AsyncQueue.cs @ 127:d86da8d2d4c3 v2
fixed AsyncQueue iterator
author | cin |
---|---|
date | Tue, 27 Jan 2015 18:18:29 +0300 |
parents | f803565868a4 |
children | 6241bff0cd64 |
line wrap: on
line diff
--- a/Implab/Parallels/AsyncQueue.cs Mon Jan 26 02:12:01 2015 +0300 +++ b/Implab/Parallels/AsyncQueue.cs Tue Jan 27 18:18:29 2015 +0300 @@ -44,6 +44,10 @@ get { return m_hi; } } + public int Size { + get { return m_size; } + } + public bool TryEnqueue(T value, out bool extend) { var alloc = Interlocked.Increment(ref m_alloc) - 1; @@ -562,9 +566,15 @@ m_pos = m_current.Low; else m_pos++; + if (m_pos == m_current.Hi) { + + m_current = m_pos == m_current.Size ? m_current.next : null; + m_pos = 0; - m_current = m_current.next; + + if (m_current == null) + return false; } return true;