[odb-users] Wrapping existing members with std::atomic<>

Andrew Cunningham odb at a-cunningham.com
Fri Jul 14 10:25:03 EDT 2017


Hi Boris,
That's correct. I do not need to worry about atomicity during DB
operations.
It's used when I am doing multi-threaded operations on the objects after
they are loaded.

Andrew

On Fri, Jul 14, 2017 at 12:58 AM, Boris Kolpackov <boris at codesynthesis.com>
wrote:

> Andrew Cunningham <andrew at a-cunningham.com> writes:
>
> >                 I need to take some of my 'existing' persistent member
> > variables (typically int and bool) and wrap them in std::atomic<> without
> > messing with my schema.
>
> I think the "proper" way to handle this would be to define the
> odb::wrapper_traits specialization for std::atomic, similar to
> nullable, optional, smart pointers, etc. For an example, see the
> specialization for boost::optional in libodb-boost (files of
> interest are optional.options and optional/wrapper-traits.hxx in
> the odb/boost/ subdirectory). Except in your case it won't be a
> NULL handler.
>
> There is one snag with this approach: the odb::wrapper_traits
> interface expects you to return references to the underlying
> value. I think there is a way to make it work if you don't
> need atomicity during database operations. Is this a reasonable
> assumption in your case?
>
> Boris
>


More information about the odb-users mailing list