Add ConcurrentQueue<T> Clear method#13976
Add ConcurrentQueue<T> Clear method#13976AlexRadch wants to merge 14 commits intodotnet:masterfrom AlexRadch:ConcurrentQueue.Clear
Conversation
| while (!IsEmpty) | ||
| { | ||
| Segment head = _head; | ||
| head.Clear(); |
There was a problem hiding this comment.
This is a lot of additional code. Is it measurably more efficient than just doing:
T item;
while (TryDequeue(out item));? It looks like it's essentially a copy of the TryDequeue/TryRemove implementation, just with Clear/Clear naming, so I wouldn't expect it would be, unless I'm missing something. We shouldn't be adding all of this extra complicated code unless it actually makes a meaningful difference.
There was a problem hiding this comment.
TryDequeue remove only one element per call see if (Interlocked.CompareExchange(ref _low, lowLocal + 1, lowLocal) == lowLocal) code.
But head.Clear() remove all elements in Segment per call see if (Interlocked.CompareExchange(ref _low, highLocal + 1, lowLocal) == lowLocal) code.
There was a problem hiding this comment.
I see. Ok. Please add a comment highlighting that fairly subtle difference between the two implementations.
There was a problem hiding this comment.
I added comment and created tests. But I have issues with config files to add API correctly.
|
I added comment about Clear method. |
|
@AlexRadch Can you cleanup the merge commits and have only your commits in history.. Also there's a compiler error: missing semicolon, Please run tests locally, running |
|
I tried to remove excess commits but I did not find how to do this so I think I have only one way - recreate my corefx fork. So I will close all my PRs, will recreate my corefx fork and will create new PRs. |
|
As per #14084 (comment), it'll probably be easiest for you to wait for @justinvp to finish #13828 before proceeding with this change. |
|
@stephentoub Ok. Thanks. |
|
@AlexRadch I see #13828 is now merged so you should be unblocked to finish this PR. |
|
@AlexRadch do you plan to finish it? |
|
@AlexRadch any update? |
|
Thanks for your work on this, @AlexRadch. Since this has been sitting for a couple of months and needed to be significantly updated based on changes to the target types, I went ahead and took your commits and created a new PR at #15292. |
Implement ConcurrentQueue.Clear API. See https://github.com/dotnet/corefx/issues/2338