Mercurial > pub > ImplabNet
comparison 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 |
comparison
equal
deleted
inserted
replaced
126:f7b2b8bfbb8c | 127:d86da8d2d4c3 |
---|---|
40 get { return m_low; } | 40 get { return m_low; } |
41 } | 41 } |
42 | 42 |
43 public int Hi { | 43 public int Hi { |
44 get { return m_hi; } | 44 get { return m_hi; } |
45 } | |
46 | |
47 public int Size { | |
48 get { return m_size; } | |
45 } | 49 } |
46 | 50 |
47 public bool TryEnqueue(T value, out bool extend) { | 51 public bool TryEnqueue(T value, out bool extend) { |
48 var alloc = Interlocked.Increment(ref m_alloc) - 1; | 52 var alloc = Interlocked.Increment(ref m_alloc) - 1; |
49 | 53 |
560 | 564 |
561 if (m_pos == -1) | 565 if (m_pos == -1) |
562 m_pos = m_current.Low; | 566 m_pos = m_current.Low; |
563 else | 567 else |
564 m_pos++; | 568 m_pos++; |
569 | |
565 if (m_pos == m_current.Hi) { | 570 if (m_pos == m_current.Hi) { |
571 | |
572 m_current = m_pos == m_current.Size ? m_current.next : null; | |
573 | |
566 m_pos = 0; | 574 m_pos = 0; |
567 m_current = m_current.next; | 575 |
576 if (m_current == null) | |
577 return false; | |
568 } | 578 } |
569 | 579 |
570 return true; | 580 return true; |
571 } | 581 } |
572 | 582 |