
You don't need the mutex. Look at the recent sp_counted_base_spin.hpp.
I just preferred to fail to general mutex when atomic ops are missing. In any case it looks like this happens only on Linux-non-x86 platforms and on Linux mutex is already userspace operation (thanks to futexes) I did this mostly for simplistically hopefully that no-implementations would use mutex finaly.
No need to use atomic_set in the constructor. If your constructor races with another member, atomics won't save you.
I know. It was just for simplicity. Not much hard.
With all due respect, may I submit that the reason it was so easy to make shared_ptr ABI-stable was that it was designed with this in mind?
Yes indeed :-) it felt this. Just boost-version is not provide this ABI stability.
shared_ptr was frequently criticised for having too much overhead and being too slow, and it was an intentional design decision to allow add_ref/release to be inlined. I knew that on most relevant architectures this didn't provide any significant performance benefit
This is fully reasonable because in reality calls are much cheaper then any atomic operation.
(even making them virtual is affordable - and this is another interesting tradeoff, allowing ABI-incompatible shared_ptr instances to coexist),
That is really interesting. It would indeed solve the ABI issues even without creating separate library. Thus each library would use the shared_ptr ABI created by the original object creator.
but C++ programmers are notoriously picky.
Or... Have too many prejudices like virtual functions are heavy or inlining solves every possible performance problem that is not true.
Besides, Boost was entirely header-only at the time shared_ptr was first designed and implemented, and had no build system.
I think that for boost as-is today it is more then fine to have header only shared_ptr
In any event, the ABI-stable shared_ptr is spelled std::shared_ptr.
Amen!!! If most of compilers I want to support had C++0x library I would not have to use 80% of boost I use today. Artyom. P.S.: Thanks for looking to my code.