Returns true
iff object
is a non-@objc
class instance with
a single strong reference.
- Does not modify
object
; the use ofinout
is an implementation artifact. - If
object
is an Objective-C class instance, returnsfalse
. - Weak references do not affect the result of this function.
Useful for implementing the copy-on-write optimization for the deep storage of value types:
mutating
func
modifyMe
(
arg
:
X
) {
if
isUniquelyReferencedNonObjC
(
&
myStorage
) {
myStorage
.
modifyInPlace
(
arg
)
}
else
{
myStorage
=
self
.
createModified
(
myStorage
,
arg
)
}
}
This function is safe to use for mutating
functions in
multithreaded code because a false positive would imply that there
is already a user-level data race on the value being mutated.
Returns
true
iffobject
is a non-@objc
class instance with a single strong reference.object
; the use ofinout
is an implementation artifact.object
is an Objective-C class instance, returnsfalse
.Useful for implementing the copy-on-write optimization for the deep storage of value types:
This function is safe to use for
mutating
functions in multithreaded code because a false positive would imply that there is already a user-level data race on the value being mutated.Declaration
func
isUniquelyReferencedNonObjC
<
T
:
AnyObject
>
(
inout
object
:
T
) -
>
Bool