Mercurial > pub > ImplabNet
comparison Implab/Parallels/AsyncQueue.cs @ 137:238e15580926 v2
added the blocking queue
| author | cin | 
|---|---|
| date | Mon, 16 Feb 2015 17:48:39 +0300 | 
| parents | 671f60cd0250 | 
| children | 8d5de4eb9c2c | 
   comparison
  equal
  deleted
  inserted
  replaced
| 136:e9e7940c7d98 | 137:238e15580926 | 
|---|---|
| 156 | 156 | 
| 157 /// <summary> | 157 /// <summary> | 
| 158 /// Adds the specified value to the queue. | 158 /// Adds the specified value to the queue. | 
| 159 /// </summary> | 159 /// </summary> | 
| 160 /// <param name="value">Tha value which will be added to the queue.</param> | 160 /// <param name="value">Tha value which will be added to the queue.</param> | 
| 161 public void Enqueue(T value) { | 161 public virtual void Enqueue(T value) { | 
| 162 var last = m_last; | 162 var last = m_last; | 
| 163 // spin wait to the new chunk | 163 // spin wait to the new chunk | 
| 164 bool extend = true; | 164 bool extend = true; | 
| 165 while (last == null || !last.TryEnqueue(value, out extend)) { | 165 while (last == null || !last.TryEnqueue(value, out extend)) { | 
| 166 // try to extend queue | 166 // try to extend queue | 
| 182 /// Adds the specified data to the queue. | 182 /// Adds the specified data to the queue. | 
| 183 /// </summary> | 183 /// </summary> | 
| 184 /// <param name="data">The buffer which contains the data to be enqueued.</param> | 184 /// <param name="data">The buffer which contains the data to be enqueued.</param> | 
| 185 /// <param name="offset">The offset of the data in the buffer.</param> | 185 /// <param name="offset">The offset of the data in the buffer.</param> | 
| 186 /// <param name="length">The size of the data to read from the buffer.</param> | 186 /// <param name="length">The size of the data to read from the buffer.</param> | 
| 187 public void EnqueueRange(T[] data, int offset, int length) { | 187 public virtual void EnqueueRange(T[] data, int offset, int length) { | 
| 188 if (data == null) | 188 if (data == null) | 
| 189 throw new ArgumentNullException("data"); | 189 throw new ArgumentNullException("data"); | 
| 190 if (length == 0) | 190 if (length == 0) | 
| 191 return; | 191 return; | 
| 192 if (offset < 0) | 192 if (offset < 0) | 
