[Development] QIntrusiveSharedPointer

Philippe philwave at gmail.com
Thu Aug 8 11:33:04 CEST 2019


> No. When you call detach(), you're in a mutating function of the object 
> and you can assume that you're the only thread executing on a member 
> function of that thread, because if that's not the case, you're in UB 
> land. Only const methods are allowed to execute concurrently on the same 
> object. Mutators must get exclusive access.

Absolutly right, but a  method "isDetached()" which is const 
has no usefulness on its own, independently from a detach() procedure.
This is the purpose of my orginal remark.

Philippe


On Thu, 08 Aug 2019 12:00:11 +0300
"Mutz, Marc via Development" <development at qt-project.org> wrote:

> On 2019-08-08 11:29, Philippe wrote:
> > Yet, what is the usefullness of qIntrusiveDetached()?
> 
> qIntrusiveDetached() makes it possible to use std::atomic ref counts 
> (which don't have ref() and deref()). It's separate from 
> qIntrusiveClone() because the latter is more often overloaded than the 
> former (cf. QTimeZone followup change).
> 
> > Because the result depends on a relaxed load, hence the moment after
> > qIntrusiveDetached() was evaluated, rechecking qIntrusiveDetached()
> > could give a different result.
> 
> No. When you call detach(), you're in a mutating function of the object 
> and you can assume that you're the only thread executing on a member 
> function of that thread, because if that's not the case, you're in UB 
> land. Only const methods are allowed to execute concurrently on the same 
> object. Mutators must get exclusive access.
> 
> HTH,
> Marc
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development





More information about the Development mailing list