relayrides/pushy — pull request #47 by jchambers (2014-02-05 23:05:22+00:00)
Title: Threadless connections

This change ditches the notion of an `ApnsClientThread` in favor of the new `ApnsConnection`. The former was a complicated state machine that would try to reconnect whenever something went wrong. The latter is much simpler and just tries to shut down gracefully when the remote end closes the connection.

This change is a bit of a monster, but I think it makes things *much* clearer and more testable. By introducing the `ApnsConnectionListener` interface, we also clarify and more cleanly separate responsibilities. The other major benefit here is that we no longer use one thread per concurrent connection; now we just create a single dispatch thread per `PushManager`.

I also took this opportunity to simplify the `SentNotificationBuffer` class. This iteration uses a `LinkedList` for storage instead of a wacky custom ring buffer; in some cases, this *may* be less efficient, but I think the gains in terms of simplicity are worth it, and this may actually not be any worse performance-wise in practice.

This pull request depends on #46.