X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Core%2FSystem.Linq.Parallel%2FOrderingEnumerator.cs;h=40023031dccdf704700f4958b4756b3ed3d0f4b6;hb=9f3ef8e4bac11601a2cf2670cbab337e6276103b;hp=e1f35dbcef2732aba899d1d8248da16b914aff2e;hpb=a7cdfb17174531750c9a24e520f94b946777993c;p=mono.git diff --git a/mcs/class/System.Core/System.Linq.Parallel/OrderingEnumerator.cs b/mcs/class/System.Core/System.Linq.Parallel/OrderingEnumerator.cs index e1f35dbcef2..40023031dcc 100644 --- a/mcs/class/System.Core/System.Linq.Parallel/OrderingEnumerator.cs +++ b/mcs/class/System.Core/System.Linq.Parallel/OrderingEnumerator.cs @@ -24,7 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#if NET_4_0 +#if NET_4_0 || MOBILE using System; using System.Threading; using System.Collections; @@ -37,7 +37,7 @@ namespace System.Linq.Parallel { internal class SlotBucket { - readonly ConcurrentDictionary temporaryArea = new ConcurrentDictionary (); + readonly TemporaryArea temporaryArea = new TemporaryArea (); readonly KeyValuePair[] stagingArea; long currentIndex; @@ -130,31 +130,25 @@ namespace System.Linq.Parallel Skim (); while (!stagingCount.IsSet) { - if (!participantCount.IsSet) + if (!participantCount.IsSet) { try { stagingCount.Wait (mergedToken); } catch { Skim (); } + } - - // Ok so basically we hit the case where we return null but there is actually - // every remaining element inside temporaryArea. Thing is that index are basically getting messed up (probably) - // So Skim doesn't see them and inaccurately say there is nothing remaining. - // To prove this, adding a if (temporaryArea.IsEmpty) before returning null result in infinite loop - // plus if it was a problem with something here it would show elsewhere so the problem definitely comes from - // SelectMany. if (participantCount.IsSet) { if (Skim ()) continue; // Totally finished - if (stagingArea.Any (s => s.Key != -1)) + if (stagingArea[0].Key != -1) break; else return null; } } - + return stagingArea; } }