F
falcon
I have a fairly large collection of data (queue), this queue has
several different different consumers which must be able to access the
queue without effecting other consumers' view of the queue. In other
words, if consumerA pops an item off the queue, consumerB should still
see that same item in the list until it pops it off.
Obviously I'll need one primary queue and one 'reference' queue for
each of the consumers. What is the best way to do this? I know I
shouldn't just make a complete copy of the whole thing, I can save
space by having references to objects in the primary queue...wondering
if there is an established design pattern...better yet, existing code!
Secondly, this will take place in a concurrent environment. My
consumers may come and go (that's why the primary queue will need to
retain its data as long as the application is running...never assuming
that no more consumers will need it).
I thought that since BlockingQueue is designed to be used specifically
in a Producer/Consumer scenario, its iterator might solve the problem
for me, but apparently if I get my blocking queue's iterator, and after
that some item is added the queue, my iterator may not reflect the
change (which obviously means that the iterator is useless for
concurrent environments).
Any ideas? Thanks!
several different different consumers which must be able to access the
queue without effecting other consumers' view of the queue. In other
words, if consumerA pops an item off the queue, consumerB should still
see that same item in the list until it pops it off.
Obviously I'll need one primary queue and one 'reference' queue for
each of the consumers. What is the best way to do this? I know I
shouldn't just make a complete copy of the whole thing, I can save
space by having references to objects in the primary queue...wondering
if there is an established design pattern...better yet, existing code!
Secondly, this will take place in a concurrent environment. My
consumers may come and go (that's why the primary queue will need to
retain its data as long as the application is running...never assuming
that no more consumers will need it).
I thought that since BlockingQueue is designed to be used specifically
in a Producer/Consumer scenario, its iterator might solve the problem
for me, but apparently if I get my blocking queue's iterator, and after
that some item is added the queue, my iterator may not reflect the
change (which obviously means that the iterator is useless for
concurrent environments).
Any ideas? Thanks!