[boost] [interprocess] atomic<offset_ptr>

34 views
Skip to first unread message

Tim Blechmann

unread,
Feb 19, 2013, 8:05:44 AM2/19/13
to bo...@lists.boost.org
hi ion,

i was wondering, what would be the best way to provide an
atomic<offset_ptr>? it cannot be used out of the box, as offset_ptr does
not conform to the std/boost::atomic<> requirements.
afaict, one would have to pre-compute the offset for a specific memory
location when performing a compare_exchange or store and fix up the
offset after an atomic load. to do that, it will probably be required to
access some internals of the offset_ptr.

also, if i'm going to work on it (not sure if i will have time), where
shall the implementation go? in a way, i'd rather put it into
interprocess than into atomic.

thoughts?
cheers, tim


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Ion Gaztañaga

unread,
Feb 19, 2013, 12:15:43 PM2/19/13
to bo...@lists.boost.org
El 19/02/2013 14:05, Tim Blechmann escribió:
> hi ion,
>
> i was wondering, what would be the best way to provide an
> atomic<offset_ptr>? it cannot be used out of the box, as offset_ptr does
> not conform to the std/boost::atomic<> requirements.

Right, it's not trivially copyable.

> afaict, one would have to pre-compute the offset for a specific memory
> location when performing a compare_exchange or store and fix up the
> offset after an atomic load. to do that, it will probably be required to
> access some internals of the offset_ptr.

Ok maybe we need to store an atomic<OffsetType> inside
atomic<offset_ptr> and add a new constructor to offset_ptr taking an
address and an offset. Would that be enough?

> also, if i'm going to work on it (not sure if i will have time), where
> shall the implementation go? in a way, i'd rather put it into
> interprocess than into atomic.

No problem to add atomic_offset_ptr.hpp to Interprocess.

Best,

Ion

Ion Gaztañaga

unread,
Feb 19, 2013, 2:55:02 PM2/19/13
to bo...@lists.boost.org
El 19/02/2013 18:15, Ion Gaztañaga escribió:

> Ok maybe we need to store an atomic<OffsetType> inside
> atomic<offset_ptr> and add a new constructor to offset_ptr taking an
> address and an offset. Would that be enough?

We already have a function to get the internal offset to complement the
constructor:

offset_type get_offset() const
{ return this->internal.m_offset; }
Reply all
Reply to author
Forward
0 new messages