[swift-dev] Thread safety of weak properties
Kevin Ballard
kevin at sb.org
Tue Dec 15 00:41:57 CST 2015
On Mon, Dec 14, 2015, at 07:48 PM, Greg Parker wrote:
>
> > On Dec 14, 2015, at 7:39 PM, Kevin Ballard <kevin at sb.org> wrote:
> >
> >> On Mon, Dec 14, 2015, at 07:34 PM, Greg Parker wrote:
> >>
> >>> On Dec 14, 2015, at 7:26 PM, Kevin Ballard via swift-dev <swift-dev at swift.org> wrote:
> >>>
> >>>> On Mon, Dec 14, 2015, at 12:19 PM, Greg Parker via swift-dev wrote:
> >>>>
> >>>>> On Dec 14, 2015, at 9:47 AM, John McCall via swift-dev <swift-dev at swift.org> wrote:
> >>>>>
> >>>>>> On Dec 12, 2015, at 7:04 PM, Chris Lattner <clattner at apple.com> wrote:
> >>>>>> #3 sounds like a great approach to me. I agree with Kevin that if we keep the object husk approach that any use of a weak pointer that returns nil should drop any reference to a husk.
> >>>>>
> >>>>> Spin locks are, unfortunately, illegal on iOS, which does not guarantee progress in the face of priority inversion.
> >>>>
> >>>> There is a spinlock algorithm that does work (in practice if not in theory), but it requires a full word of storage instead of a single bit.
> >>>
> >>> Is that what OSSpinLock uses?
> >>
> >> It does not. OSSpinLock is unsafe unless you can guarantee that all users have the same priority.
> >
> > Hmm, that's pretty unfortunate to hear. I've written code with spinlocks on iOS, and I imagine I'm not the only one. Does the system provide an implementation of this "safe in practice" spinlock that's visible to third-party devs?
>
> Not that I know of. You should file a bug report.
Filed as rdar://problem/23896366.
-Kevin Ballard
More information about the swift-dev
mailing list