[concurrency-interest] Timestamps-based ConcurrentMap

Jean Morissette jean.morissette at gmail.com
Fri Mar 10 14:45:16 EST 2006


2006/3/9, David Holmes <dcholmes at optusnet.com.au>:
> It sounds like you want to make an atomic snapshot of the map and iterate
> over that.

Right.

> The timestamp idea seems only a partial solution depending on what your
> constraints actually are: you can't stop entries being removed, you can only
> skip entries that have been added since, if they appear.

Each entry could have two timestamps, one for its creation and one set
at its removal. Removed entries would remain in the map until there is
no iterator that can see them, after which they would be (lazily?)
removed.

> Why not just use an iterator to make your own immutable snapshot that can
> then be accessed by other threads.

In my scenario, there is as mush map update (put/remove) than querying
(iterator) operations. Also, the size of these map can be really big. 
So, using a copy strategy to create a snapshot seems costly: it would
involve a lot of copying. What do you think?

Thanks,
Jean



More information about the Concurrency-interest mailing list