Boost logo

Boost :

Subject: Re: [boost] GSOC 2015 : Project on Concurrent Hash Tables
From: Amarnath V A (me_at_[hidden])
Date: 2015-03-06 23:36:28

On Fri, Mar 6, 2015 at 7:00 PM, Niall Douglas <s_sourceforge_at_[hidden]> wrote:
> Move construction of the map != move construction of the buckets.

Okay. I am trying to achieve move construction in the same spirit. And
I am piggybacking on Niall's implementation of _rehash().

      concurrent_unordered_map(concurrent_unordered_map &&old_map)
        typedef decltype(_rehash_lock) rehash_lock_t;
        lock_guard<rehash_lock_t> guard(old_map._rehash_lock,
        size_t n = old_buckets.size();
          // Lock all existing buckets
          for(auto &b : old_buckets)

        buckets_type *tempbuckets=new buckets_type(13);
        auto untempbuckets=undoer([&tempbuckets]{ delete tempbuckets; });

        buckets_type *buckets=new buckets_type(n);

        // Swap old buckets with new buckets,
        // Tell all threads using old buckets to start reloading the bucket list
        for(auto &b : *tempbuckets)

        // Simply move the old buckets into new buckets as-is
        for(auto obit=tempbuckets->begin(), bit=buckets->begin();
obit!=tempbuckets->end(); ++obit, ++bit)
          auto &ob=*obit;
          auto &b=*bit;
  , memory_order_release);

Is this the right direction?

> Old buckets go into a fixed size ring buffer, and get deleted
> eventually.

I couldn't really figure out where the ring buffer is which you are
mentioning here. What am I missing?

And another question, when I use the above implementation of move
constructor and later call empty() on the newly created object, I land
in a segfault. I see that the empy() checks on if the lock state is 2
and continues to check the next bucket. But, I think here I have all
buckets set to lock state 2. Why did the swap I performed with the
tempbuckets and oldmap._buckets not help me? Any pointers will be
really helpful.


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