Boost logo

Boost :

Subject: Re: [boost] GSOC 2015 : Project on Concurrent Hash Tables
From: Amarnath V A (me_at_[hidden])
Date: 2015-02-24 22:00:36


Thanks for the frank reply Niall. Firstly, I am interested in working with
this project regardless of whether I get selected for GSoC. I am willing to
learn C++11 and try to contribute high quality code to Boost. Secondly, I
don't mind other candidates leveraging on the code I have written. I
believe that's the whole point of open source. Yeah, I understand GSoC is
competitive but I am a firm believer that we should keep the best interests
of the community over individuals.

I have decided to share the piece of code I have written. From what I
understand, the code is serving the basic needs of move constructor and
move assignment. As I have not extensively used C++11, I am quite unsure of
anything else that I have to add to these to make the code more efficient
and maintainable.

I am just sharing the diff of the source code. I have skipped the diff of
unittests here. Please point out any issues or improvements I can work on.
Thanks in advance.

- concurrent_unordered_map(const concurrent_unordered_map &);
- concurrent_unordered_map(concurrent_unordered_map &&) BOOST_NOEXCEPT;
+ concurrent_unordered_map(const concurrent_unordered_map &);
       concurrent_unordered_map &operator=(const concurrent_unordered_map
&);
- concurrent_unordered_map &operator=(concurrent_unordered_map &&)
BOOST_NOEXCEPT;
     public:
+ concurrent_unordered_map(concurrent_unordered_map &&old_map)
BOOST_NOEXCEPT : _hasher(std::move(old_map._hasher)),
_key_equal(std::move(old_map._key_eq
+ {
+ //Hold the rehash lock
+ typedef decltype(_rehash_lock) rehash_lock_t;
+ typedef decltype(old_map._rehash_lock) old_rehash_lock_t;
+ lock_guard<rehash_lock_t> guard(_rehash_lock, adopt_lock_t());
+ lock_guard<old_rehash_lock_t> old_guard(old_map._rehash_lock,
adopt_lock_t());
+ _buckets.exchange(old_map._buckets.load(memory_order_consume),
memory_order_release);
+ old_map._buckets.exchange(nullptr, memory_order_acq_rel);
+ old_map._buckets = new buckets_type(13);
+ old_map._oldbucketit = old_map._oldbuckets.begin();
+ old_map._oldbuckets.fill(nullptr);
+ }
+
+ concurrent_unordered_map &operator=(concurrent_unordered_map
&&old_map) BOOST_NOEXCEPT
+ {
+ if (this != &old_map) {
+ //Hold the rehash lock
+ typedef decltype(_rehash_lock) rehash_lock_t;
+ typedef decltype(old_map._rehash_lock) old_rehash_lock_t;
+ lock_guard<rehash_lock_t> guard(_rehash_lock, adopt_lock_t());
+ lock_guard<old_rehash_lock_t> old_guard(old_map._rehash_lock,
adopt_lock_t());
+ _buckets.exchange(old_map._buckets.load(memory_order_consume),
memory_order_release);
+ _hasher = std::move(old_map._hasher);
+ _key_equal = std::move(old_map._key_equal);
+ _max_load_factor = std::move(old_map._max_load_factor);
+ _min_bucket_capacity = std::move(old_map._min_bucket_capacity);
+ old_map._buckets.exchange(nullptr, memory_order_acq_rel);
+ old_map._buckets = new buckets_type(13);
+ old_map._oldbucketit = old_map._oldbuckets.begin();
+ old_map._oldbuckets.fill(nullptr);
+ }
+ return *this;
+ }

Thanks,
Amarnath

On Tue, Feb 24, 2015 at 8:40 PM, Niall Douglas <s_sourceforge_at_[hidden]>
wrote:

> On 24 Feb 2015 at 17:30, Amarnath V A wrote:
>
> > I have coded the move constructor and move assignment operator. I am not
> > sure how good the code is. (Again, let me reiterate I am new to C++11).
> > Will have some time to look at that? Should I share it here in the lists
> or
> > should I send you a private mail?
>
> It wouldn't be appropriate for me as the likely mentor to comment on
> anything specifically until GSoC student applications have closed,
> and then I can treat all submissions equally and fairly. So someone
> else here will have to comment on your work specifically, as I can
> only comment in very general and non-specific terms.
>
> Regarding whether to post here with your effort for the community to
> inspect your work ... well, other candidates you might be competing
> against will see it as well. They may be able to leverage the
> discussion here to submit a better application than you. You may find
> no one here answers, and posting your answer here hasn't benefited
> you at all.
>
> That said, and assuming anyone bothers to review your work, the fact
> you were here so early and asked for help in the right kind of way
> looks very positive, even if your written application compares poorly
> to another. There is also a valid point that if more of the community
> who rank GSoC applications have seen your coding skills now AND your
> coding skills are above average, then the chances are they will rank
> you more favourably.
>
> Similarly, if your coding skills are below average, the community may
> well remember that and penalise you for it. If, however, you react
> really well to critique and show a rapid and marked improvement, then
> that might favour you.
>
> I do apologise for the equivocal answer. I just wanted you to be
> aware that there are risks in either route, but there are also
> benefits. I would say that Boost is an open source software
> community, and its culture and how it judges others reflects that.
> Past that, the decision must be yours alone.
>
> Niall
> ---
> Boost C++ Libraries Google Summer of Code 2015 admin
> https://svn.boost.org/trac/boost/wiki/SoC2015
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk