Netflix/RxJava — pull request #807 by akarnokd (2014-02-05 09:17:48+00:00)
Title: Operator Repeat and other operator fixes

Reimplemented repeat() which exposed some other problems.

- Added ```QueueDrain``` based on [this](http://twistedoakstudios.com/blog/Post8424_deadlocks-in-practice-dont-hold-locks-while-notifying).
- Added overload of repeat(long n) to repeat a source n times (which is not the same as repeat().take(n) generally). Note that Ben's prototype was not working correctly because it run the re-subscription code in a loop: if subscribeOn was used, it was constantly resubscribing before the old even finished.
- For some reason, observeOn+take didn't work as expected, causing repeat tests to fail as well. I couldn't determine the cause. I've noticed that ```take``` was unable to unsubscribe the upstream as there was nothing in its ```cs```.
- To fix the problem above, I've reimplemented observeOn as well. It does not use recursive scheduling but the QueueDrain.
- This exposed another problem with GroupBy: in some cases, childObserver.onCompleted was sent out twice, breaking merge/flatMap. I've added a once check, but I'm not 100% certain there isn't anything else wrong with the GroupBy's staggered behavior.
- Unfortunately, ```OperationParallelMergeTest``` is broken with this PR. I don't quite understand why it doesn't work nor have a clue how to fix it or the new ```observeOn```. Maybe the parallel tests relied on thread timing and not expiring too fast so they could continue one them.