[swift-dev] Thread safety of weak properties

John McCall rjmccall at apple.com
Mon Dec 14 11:47:01 CST 2015


> 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.

John.

> 
> -Chris
> 
>> On Dec 11, 2015, at 7:00 AM, Mike Ash via swift-dev <swift-dev at swift.org> wrote:
>> 
>> 3. Borrow a bit from the weak pointer to implement a spinlock. This is really a special case of (2), with the activity count being capped at 1 and additional activity blocking. In fact, you could even do a hybrid approach by borrowing more bits. (I think it could safely steal up to 20 bits with current 64-bit architectures. This may not be wise. As long as targets are pointer-aligned you can safely steal 2/3 bits.)



More information about the swift-dev mailing list