ReactiveCocoa/ReactiveCocoa — pull request #859 by keithduncan (2013-10-11 11:07:03+00:00)
Title: Fix ownership race condition when swapping disposables

In `RACSerialDisposable` the compare and swap loop only took ownership after the swap was successful. This leaves an opportunity for another thread to come in and perform a subsequent swap, and `CFBridgingRelease` the value that the first thread swapped in, before the first thread has finished retaining the value.

Instead, retain the disposable before performing the swap, and release it in the event that the swap fails.

This would be extremely hard to test because our tests target is ARC and is inserting retains of the arguments.