davedelong/CHCSVParser — pull request #46 by MihaiDamian (2013-07-15 12:59:58+00:00)
Title: Modified _loadMoreIfNecessary to wait until the stream has available data

The parser currently stops if the input stream has no available bytes to read. This seems incorrect as parsing should normally continue until the stream is closed, at an end or when an error has occurred. If hasBytesAvailable returns no it doesn't imply any of these cases, it could just be that the input stream is not yet ready to hand out data.

I encountered this limitation while trying to set up a producer-consumer relation between a network operation that downloaded a CSV and CHCSVParser. Because of network delays the parser can often read from the stream faster than the network operation can write.

The solution in this pull request is to wait in _loadMoreIfNecessary until further data is available, the stream ends or parsing is canceled.