I am trying to come up with the best data structure for use in a high throughput C++ server. The data structure will be used to store anything from a few to several million obje
You have 3 types of tasks:
If near consistency is good enough then keep track of the # of active iteration tasks.
If iterations tasks are active and a new insert or deletion tasks comes in queue those tasks for later processing (but you can return the to caller right away)
As soon as the last iteration if finished process queued inserts and deletes.
If an iteration request comes in while inserts or deletes are pending then queue it up.
If an iteration request comes in while there are just iterations running just have it go and iterate.
You should still write the iteration to be as fast as possible by making a copy of the data you are iterating over and then process that data in the client if the actual data processing takes a lot more time than the iteration itself.
I would implement the main collection with a hashtable or stl:map might even be fast enough. Insert/Delete requests could be queued in a list.