This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Commit 6b291a4
committed
Rewrite ConcurrentQueue for better performance
This commit rewrites ConcurrentQueue<T> to provide better throughput and a much better allocation profile. As with the previous implementation, it's structured as a linked list of segments. Unlike the previous implementation, these segments are now ring buffers, allowing them to be reused as long as they're not full; if an enqueue does make a segment full, then a new segment is created for subsequent enqueues. Also unlike the previous implementation, segments are dynamic in size, so newly allocated segments follow a doubling scheme similar to that employed by other generic collections. The synchronization mechanism used is also lower-overhead than before, with a typical operation incurring just one CAS operation to either enqueue or dequeue.1 parent 3e6bedf commit 6b291a4
5 files changed
Lines changed: 792 additions & 636 deletions
File tree
- src/System.Collections.Concurrent
- src
- Resources
- System/Collections/Concurrent
- tests
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
| 186 | + | |
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
280 | | - | |
| 280 | + | |
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
| |||
0 commit comments