[concurrency-interest] COWList snapshot.

Владимир Озеров ppozerov at gmail.com
Wed Feb 19 09:21:14 EST 2014


I was a little bit suprized when found that there is no convenient way to
get snapshot of COW list.
What I need is to get snapshot of the list (in form of either array or
List, doesn't matter) and perform several reads on it (index lookups or
traversals). For this reason I cannot use iterator. Also I would like to
avoid unnecessary array copying since I'm not going to perform writes. So
getting internal array appears to be the best way to do that from
performance perspective. Copying constructor and forEach() method already
employ this technique in JDK8 (

For now there is no way to get that array since all access to it are either
private or package-scoped. Could something like "List<T> snapshot()" be
added to COWList API returning unmodifiable wrapper over internal array? Or
at least getArray() could be made protected so that developers can use it
on their own risk :-)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140219/13cc21a6/attachment.html>

More information about the Concurrency-interest mailing list