Open GoogleCodeExporter opened 9 years ago
Actually, ConcurrentBag<T> works fine, because it implements `IEnumerable` and
has an `Add` method, which is one of the supported scenarios.
`ConcurrentQueue<T>` does *not*, because it doesn't have those. However, I
support we could look for the `IProducerConsumerCollection<T>` interface and
use `TryAdd`
Original comment by marc.gravell
on 28 Jan 2013 at 10:21
For info, with only a couple of changes I have it working for everything except
stack (which gets inverted); a quick validation shows that Queue<T> and
Stack<T> are not supported in the non-concurrent code; for now (to avoid
issues), I propose to make the concurrent Queue/Stack equally unsupported,
while I think about sane ways to implement it (probably using the TryTake
method) - but bags and collections should work
Original comment by marc.gravell
on 28 Jan 2013 at 11:10
I would be most grateful for the ability to support the ConcurrentQueue as I've
become quite dependent on it lately.
TryTake will remove the item from the queue, but you can access the items by
index MyQueue(1) or maybe CopyTo an array or other collection. I'm not really
sure about the underpinning of what you do here so I'm a bit out of my element
making a suggestion.
Original comment by bviller...@gmail.com
on 28 Jan 2013 at 10:24
Just saying... there *is* an existing way to do this...
public ConcurrentQueue<int> Items {get;set;}
[ProtoMember(n)]
private int[] Items
{
get { return Items.ToArray(); }
set { Items = new ConcurrentQueue<int>(value); }
}
I agree TryTake looks like a bad choice here, so I'll count that out - but the
index approach also looks like the type of special-case code I've tried very
hard to avoid ;p
Original comment by marc.gravell
on 28 Jan 2013 at 10:34
Original issue reported on code.google.com by
bviller...@gmail.com
on 28 Jan 2013 at 9:54