Added warnings if an operation that has been dispatched onto the
main thread takes longer than a threshold.

This dumps the full callstack from the time of the dispatch if the
threshold is exceeded.

This is only enabled in DEBUG mode.

The threshold is currently set to 0.3 secs, but I expect to be able to
reduce that.
Fix a retain cycle in StreamPair.

The StreamPair instance needed a reference to each of the streams,
in order to pass them to the caller, but the streams themselves
are using the StreamPair instance as the shared buffer.

To fix this, change the initial construction of a StreamPair.  We
now use a class method to do the allocation and return the two streams,
so the caller never gets their hands on the StreamPair instance, and
it doesn't need references to the streams.
Added a null check.  This only can happen if a malloc fails.