Feature #21
closed
optionally use libatomic for atomic_t
Added by Sage Weil about 14 years ago.
Updated over 13 years ago.
Description
libatomic-ops on debian? something like that. unless there's something better.
also, probably drop the CommonC++ one, which has seemed buggy in the past (and is disabled by default)
- Assignee set to Greg Farnum
- Target version set to v0.21
- Start date changed from 04/12/2010 to 04/13/2010
- Status changed from New to 4
I've cleaned out all the CommonC++ stuff, which couldn't be used anyway since it didn't match the required interface!
A new libatomic_ops version is also implemented, using memory blocks that I believe should work. Further testing is required to see if it's any faster or more desirable than the spinlock version.
Basic testing seems to indicate it works, though!
Huh, it looks like STL has some refcounting primitives built in?
From /usr/include/c++/4.3/bits/basic_string.h:
void
_M_dispose(const _Alloc& __a)
{
#ifndef GLIBCXX_FULLY_DYNAMIC_STRING
if (_builtin_expect(this != &_S_empty_rep(), false))
#endif
if (_gnu_cxx::_exchange_and_add_dispatch(&this->M_refcount,
-1) <= 0)
_M_destroy(_a);
} // XXX MT
void
_M_destroy(const _Alloc&) throw();
_CharT*
_M_refcopy() throw()
{
#ifndef GLIBCXX_FULLY_DYNAMIC_STRING
if (_builtin_expect(this != &_S_empty_rep(), false))
#endif
_gnu_cxx::_atomic_add_dispatch(&this->_M_refcount, 1);
return _M_refdata();
} // XXX MT
- Status changed from 4 to Resolved
Also available in: Atom
PDF