maxpow4h/swiftz — pull request #37 by rnapier (2014-06-13 15:21:35+00:00)
Title: Fixes #36. Replace pthread in Future with GCD

I believe this is a better way to implement the Future using queues rather than pthread locks. The object begins with a suspended queue. All calls to `result()` are put on that queue. When a result appears, the queue is resumed and all calls to `result()` will complete. This trades three pthread calls for a single `dispatch_sync` call in every use of `result()`.

ARC will automatically clean up the queue for us as long as it is empty. If it isn't empty, then that means there are callers currently blocking on `result()`, and if that's true, then there exist strong references to us and we couldn't be deallocated anyway.