changeset 127:d86da8d2d4c3 v2

fixed AsyncQueue iterator
author cin
date Tue, 27 Jan 2015 18:18:29 +0300
parents f7b2b8bfbb8c
children 6241bff0cd64
files Implab/Implab.csproj Implab/Parallels/AsyncQueue.cs
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Implab/Implab.csproj	Mon Jan 26 02:12:01 2015 +0300
+++ b/Implab/Implab.csproj	Tue Jan 27 18:18:29 2015 +0300
@@ -7,8 +7,6 @@
     <OutputType>Library</OutputType>
     <RootNamespace>Implab</RootNamespace>
     <AssemblyName>Implab</AssemblyName>
-    <ProductVersion>8.0.30703</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
--- 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;