DESCRIPTION

JCBC-644: More efficient timeout checks when blocking.

Motivation
----------
The timeout() operator is very powerful in RxJava, but also has more
overhead and scheduling associated. In the simple case where the code
just needs to block finally and wait for a result, the latch of the
BlockingObservable can be reused - instead of waiting infinitely apply
a custom timeout.

Modifications
-------------
The BlockingObservable code with the latch has been extracted into
a utility class (for internal use only for now). All of the last
resort timeout and blocking calls have been changed to use the
extracted method instead of the Rx timeout() calls.

Note that the blocking operations which expose an Iterator on
Views and Query cannot be converted, because this optimization
only works on single-result operations.

Result
------
Less GC and scheduling overhead, because the simple blocking
latch is reused. It also avoids https://github.com/ReactiveX/RxJava/issues/1919
where possible, although not in all cases.

Change-Id: I4520ffad1a3195ea65fd8e29d01f49e10d1fc698
Reviewed-on: http://review.couchbase.org/43904
Tested-by: Natasha Sullivan xxx@xxx.xxx
Reviewed-by: Estrella Humphrey xxx@xxx.xxx


COMMENTS

author: Natasha Sullivan
date: 2014-12-03 15:39:41.458000000

Change has been successfully cherry-picked as 4317ebe46c0c1b369f24f88efcf7d48f241736dd

-------------------------------------
