Boost logo

Boost :

Subject: Re: [boost] [poly_collection] Two remarks
From: Joaquin M López Muñoz (joaquinlopezmunoz_at_[hidden])
Date: 2017-05-10 15:31:48

El 09/05/2017 a las 14:27, Dominique Devienne via Boost escribió:
> Just as Pete Bartlett mentioned, I'm also a fan of Joaquín's Multi-Index,
> which I'm used in production for many years as well.
> My only complaint about his proposed Poly-Collection is the fact I can't
> leverage and thus benefit from the performance of it, in a multi-index
> scenario, but as Joaquín already answered a few months ago, that's
> off-topic and by design, I know :)

I can't add much more to our previous conversation on this subject.
Those interested
can recover that thread from

> [...]
> My second remark is about parallelism. I suspect the new poly_collection
> could be used for more efficient parallel (and/or concurrent) processing
> of elements, and would be interested in examples and even a
> ::parallel_for_each() algorithm that leverages the collection's internal
> storage. And perhaps even on the write side, rather than having to make the
> whole container thread-safe, but external mutexing for example, provide
> ways for a more granular thread-safety by type or segment perhaps. Again,
> probably off topic, but hardly something you can "add from the outside" I
> think, and why I mention it here and now.

This is an interesting topic. It should be relatively easy to write a
parallel for_each that
spawns a parallel task for each segment, each of which can in its turn
parallelize work
on its data. I can try to play with this idea to see how it fares

As for thread safety, polymorphic containers do already have the nice
property that
concurrent writes to different (preexisting) segments can be done safely:

   boost::base_collection<sprite> c;
   std::thread t1{[&]{c.insert(warrior{0});}};
   std::thread t2{[&]{c.insert(goblin{1});}};

I can add this info to the docs.

Joaquín M López Muñoz

Boost list run by bdawes at, gregod at, cpdaniel at, john at