Pinning an object prevents it from being deallocated,
just like retaining it, but only one client can own the
pin at once. Sensible "sharing" of the pin can occur
if attempts are perfectly nested. It is efficient to
simultaneously query the pin state of an object in
conjunction with its strong reference count.
This combination of traits makes pinning suitable for
use in tracking whether a data structure backed by
an object is undergoing a non-structural modification:
- A structural change would require unique ownership
of the object, but two non-structural changes (to
different parts of the object) can occur at once
without harm. So a non-structural change can check
for either uniqueness or a pin and then, if necessary,
assert the pin for the duration of the change.
Meanwhile, this act of asserting the pin prevents
simultaneous structural changes.
- A very simple code-generation discipline leads to
changes being perfectly nested as long as they're
all performed by a single thread (or synchronously).
Asynchrony can introduce imperfect nesting, but it's
easy to write that off as a race condition and hence
undefined behavior.
See Accessors.rst for more on both of these points.
Swift SVN r23761
This is currently unimplemented as of this macro being 20141011,
when it is implemented in libstdc++ the check should be changed
to a < the version that implemented it.
Swift SVN r23368
stdint.h and stddef.h are shipped with CLang, but they not included in
Clang's module.map, which causes Clang to import libc versions instead
(and Clang's stdint.h is dispatching to libc). This was causing
hard-to-debug transient failures during incremental rebuilds, like this:
error: module file was created by an older version of the compiler: .../Darwin.swiftmodule
Swift SVN r23230
Generated code on x86_64 for swift_retain and swift_release and
swift_allocObject are unchanged. arm64 is improved by using weaker
memory barriers, fixing rdar://17423624.
Swift SVN r22887
Now that we can read definitions directly from "C" headers, stop trying
to maintain a mirror of the HeapObject struct in Swift code in the
standard library.
Swift SVN r14982