C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::big_int

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 02 Apr 2026 09:16:53 -0700
On Thursday, 2 April 2026 05:43:30 Pacific Daylight Time Frederick Virchanza
Gotham via Std-Proposals wrote:
> I'm writing this here on my phone, and at some point I'll have to sit down
> properly at a computer and think this through more, but if you're going to
> allow one thread to increment the reference of an object that's used by
> another thread, then it stands to reason that the referred object must be
> atomic too.

Nope.

You only increment the reference counter (or decrement, for that matter) when
the object is shared and therefore constant. It cannot be mutated, because
that mutation would be visible to other threads. Therefore, there's no need to
keep the data itself atomic, since it won't change and requires no
synchronisation other than what has already happened.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-04-02 16:17:02