Boost logo

Boost :

Subject: Re: [boost] Fwd: [sync?] "Distributed" value (or something...)
From: Klaim - Joël Lamotte (mjklaim_at_[hidden])
Date: 2014-07-30 04:58:51

On Wed, Jul 30, 2014 at 10:45 AM, Andrey Semashev <andrey.semashev_at_[hidden]
> wrote:

> I'm not sure I fully understood the idea but is it implementable in
> RCU manner?

Thanks for the keyword, I think it's indeed related but I wasn't aware of
the idea.
I'll have to read more ( to
be sure.

> I think you can have a mutex-protected shared_ptr to the
> value, which every reader can obtain and use. When the reader is not
> using the value it demotes it to weak_ptr. Next time the reader wants
> to use the object it attempts to promote it to shared_ptr, which will
> only succeed if the value has not expired.
That's close to the implementation I was thinking about but I also would
like to avoid any lock if avoidable.
(I lack practice in this domain to say if it's avoidable).

> This approach does not involve any callbacks, which might be a good or
> bad thing depending on the use case.

I think in my case the writes are so rarely changed but have so much impact,
I'm assuming that it's more efficient if a callback is called once the
value is written so that
the systems don't have to test the value regularly.
I might be wrong though, my application is not complete yet.

> In any case, I think this would
> be a fairly high level primitive (especially if async callbacks are
> involved), so I'm not sure Boost.Sync is the right place for it.
I was assuming it would be close to synchronized_value but it's a bit more
high-level indeed.

> _______________________________________________
> Unsubscribe & other changes:

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