This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: atomic operations for shared_ptr ?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/24/2013 08:58 PM, Bronek Kozicki wrote:
> On 24/08/2013 18:51, Jonathan Wakely wrote:
>> On 24 August 2013 18:45, Bronek Kozicki wrote:
>>> 
>>> what are the current plans for supporting atomic_* free
>>> functions for shared_ptr, as defined in C++11 (20.6.2 "Header
>>> <memory> synopsis")? These would be very useful for passing
>>> shared_ptr objects between threads, esp. if there are multiple
>>> readers and single writer.
>> 
>> I've been thinking about it recently and am probably just going
>> to implement it with a single global mutex used for all
>> shared_ptr instances.
> 
> 
> erm, but that would be even worse than using mutexes as in my
> example code ....

A while ago I was looking for a lock-free algorithm for reference
counted smart pointers, and found this:
http://www.drdobbs.com/atomic-reference-counting-pointers/184401888.
It depends on specific assembler instructions, but for machines that
have them it could really speed up concurrent access to shared_ptr,
which would be a good thing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSGcF+AAoJECkLFtN5Xr9fKJYH/0zPJnxAzfYk4N3mkXTeFJh1
k3i3gL239ZIV/M9LNf3pa26bh5nanKu0tHQMbYqiw4hrs544H2zf8KXgF1rUFHSp
jGgFBOx8Eva6pcoTkbktNteA7JuwwnnSQ52Qby0XPNe0FK3c93VsIJxLj33ghQRH
YSqwtJeZh6tZJAtCGeoh8C7qwOwjnM4JT+FQo7hRqL4W5AYofLMLibvxM2WAWPLX
qtkbyqEoDoSqLHFJX36tKxesDL8wP5oSpJsU8EPt08caCP9xbKZ+089O1pXf9QP5
2SUWxr2PjNornEUs32//JSG2HqCWKStWSUZ5XupJCXPF66TVLuEZExEXcO+kG0Y=
=rW7K
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]