marc at kdab.com
Thu Aug 8 11:00:11 CEST 2019
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.
More information about the Development