public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* std::atomic_shared_ptr
@ 2021-06-01 19:35 Mikhail Matrosov
  2021-06-02  1:57 ` std::atomic_shared_ptr Thomas Rodgers
  0 siblings, 1 reply; 7+ messages in thread
From: Mikhail Matrosov @ 2021-06-01 19:35 UTC (permalink / raw)
  To: libstdc++

Could anyone please share the status of the implementation
of std::atomic_shared_ptr?

-----
Best regards, Mikhail Matrosov

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: std::atomic_shared_ptr
  2021-06-01 19:35 std::atomic_shared_ptr Mikhail Matrosov
@ 2021-06-02  1:57 ` Thomas Rodgers
  2021-06-02  2:16   ` std::atomic_shared_ptr Thomas Rodgers
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Rodgers @ 2021-06-02  1:57 UTC (permalink / raw)
  To: Mikhail Matrosov; +Cc: libstdc++

On 2021-06-01 12:35, Mikhail Matrosov via Libstdc++ wrote:

> Could anyone please share the status of the implementation
> of std::atomic_shared_ptr?
> 
> -----
> Best regards, Mikhail Matrosov

It didn't make the cutoff for GCC11 stage1, I hope to get it into GCC12.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: std::atomic_shared_ptr
  2021-06-02  1:57 ` std::atomic_shared_ptr Thomas Rodgers
@ 2021-06-02  2:16   ` Thomas Rodgers
  2021-06-02  7:10     ` std::atomic_shared_ptr Mikhail Matrosov
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Rodgers @ 2021-06-02  2:16 UTC (permalink / raw)
  To: Mikhail Matrosov; +Cc: libstdc++

On 2021-06-01 18:57, Thomas Rodgers wrote:

> On 2021-06-01 12:35, Mikhail Matrosov via Libstdc++ wrote:
> 
>> Could anyone please share the status of the implementation
>> of std::atomic_shared_ptr?
>> 
>> -----
>> Best regards, Mikhail Matrosov
> 
> It didn't make the cutoff for GCC11 stage1, I hope to get it into 
> GCC12.

Also, to set expectations, it will not be a lock free atomic.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: std::atomic_shared_ptr
  2021-06-02  2:16   ` std::atomic_shared_ptr Thomas Rodgers
@ 2021-06-02  7:10     ` Mikhail Matrosov
  2021-06-02  9:22       ` std::atomic_shared_ptr Jonathan Wakely
  0 siblings, 1 reply; 7+ messages in thread
From: Mikhail Matrosov @ 2021-06-02  7:10 UTC (permalink / raw)
  To: Thomas Rodgers; +Cc: libstdc++

Hi, Thomas,

> It didn't make the cutoff for GCC11 stage1, I hope to get it into GCC12.

Glad to hear that!

> Also, to set expectations, it will not be a lock free atomic.

Hm. That's surprising. And honestly does not look very useful. We can
always wrap a shared_ptr in a mutex.

There exist lock-free implementations in the wild. E.g. in folly. Would it
be possible to adopt one of those?

-----
Best regards, Mikhail Matrosov

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: std::atomic_shared_ptr
  2021-06-02  7:10     ` std::atomic_shared_ptr Mikhail Matrosov
@ 2021-06-02  9:22       ` Jonathan Wakely
  2021-06-02 14:37         ` std::atomic_shared_ptr Mikhail Matrosov
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2021-06-02  9:22 UTC (permalink / raw)
  To: Mikhail Matrosov; +Cc: Thomas Rodgers, libstdc++

On Wed, 2 Jun 2021 at 08:10, Mikhail Matrosov via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> Hi, Thomas,
>
> > It didn't make the cutoff for GCC11 stage1, I hope to get it into GCC12.
>
> Glad to hear that!
>
> > Also, to set expectations, it will not be a lock free atomic.
>
> Hm. That's surprising. And honestly does not look very useful. We can
> always wrap a shared_ptr in a mutex.

Which is why some people think the feature should never have been
added to the standard in the first place.

> There exist lock-free implementations in the wild. E.g. in folly. Would it
> be possible to adopt one of those?

Probably not, because it would require ABI-breaking changes to
std::shared_ptr, which is out of the question.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: std::atomic_shared_ptr
  2021-06-02  9:22       ` std::atomic_shared_ptr Jonathan Wakely
@ 2021-06-02 14:37         ` Mikhail Matrosov
  2021-06-02 15:03           ` std::atomic_shared_ptr Thomas Rodgers
  0 siblings, 1 reply; 7+ messages in thread
From: Mikhail Matrosov @ 2021-06-02 14:37 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Thomas Rodgers, libstdc++

> Probably not, because it would require ABI-breaking changes to
std::shared_ptr, which is out of the question.

Could you please elaborate on that? I can see how folly uses
std::shared_ptr directly:

https://github.com/facebook/folly/blob/master/folly/concurrency/AtomicSharedPtr.h#L76
https://github.com/facebook/folly/blob/master/folly/concurrency/detail/AtomicSharedPtr-detail.h#L45

-----
Best regards, Mikhail Matrosov

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: std::atomic_shared_ptr
  2021-06-02 14:37         ` std::atomic_shared_ptr Mikhail Matrosov
@ 2021-06-02 15:03           ` Thomas Rodgers
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Rodgers @ 2021-06-02 15:03 UTC (permalink / raw)
  To: Mikhail Matrosov; +Cc: Jonathan Wakely, libstdc++

On 2021-06-02 07:37, Mikhail Matrosov wrote:

>> Probably not, because it would require ABI-breaking changes to
> std::shared_ptr, which is out of the question.
> 
> Could you please elaborate on that? I can see how folly uses 
> std::shared_ptr directly:
> 
> https://github.com/facebook/folly/blob/master/folly/concurrency/AtomicSharedPtr.h#L76
> https://github.com/facebook/folly/blob/master/folly/concurrency/detail/AtomicSharedPtr-detail.h#L45
> 
> -----
> Best regards, Mikhail Matrosov

I've yet to be convinced that this type warrants the extra complexity 
doing so would entail, and if I did decide to incur that level of
complexity, I would likely go a different route (see comments in folly 
re: corner cases). Either way, GCC12 won't commit to any ABI for
this, GCC13 might, and the details can change between the two releases.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-02 15:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-01 19:35 std::atomic_shared_ptr Mikhail Matrosov
2021-06-02  1:57 ` std::atomic_shared_ptr Thomas Rodgers
2021-06-02  2:16   ` std::atomic_shared_ptr Thomas Rodgers
2021-06-02  7:10     ` std::atomic_shared_ptr Mikhail Matrosov
2021-06-02  9:22       ` std::atomic_shared_ptr Jonathan Wakely
2021-06-02 14:37         ` std::atomic_shared_ptr Mikhail Matrosov
2021-06-02 15:03           ` std::atomic_shared_ptr Thomas Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).