Package com.couchbase.client.java.util
Class Blocking
- java.lang.Object
-
- com.couchbase.client.java.util.Blocking
-
@Uncommitted @Private @Deprecated public class Blocking extends Object
Deprecated.this class has been moved into core (BlockingContains various utility methods related to blocking operations.- Since:
- 2.0.2
- Author:
- Michael Nitschinger
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> TblockForSingle(rx.Observable<? extends T> observable, long timeout, TimeUnit tu)Deprecated.Blocks on anObservableand returns a single event or throws anException.
-
-
-
Method Detail
-
blockForSingle
public static <T> T blockForSingle(rx.Observable<? extends T> observable, long timeout, TimeUnit tu)Deprecated.Blocks on anObservableand returns a single event or throws anException. Note that when this method is used, only the first item emitted will be returned. The caller needs to make sure that the sourceObservableonly ever returns a single item (or none). TheBlockingObservablecode applies different operators like single, last, first and more, these need to be applied manually. This code is based onBlockingObservable.blockForSingle(rx.Observable<? extends T>), but does not wait forever. Instead, it utilizes the internalCountDownLatchto optimize the timeout case, with less GC and CPU overhead than chaining in anObservable.timeout(long, TimeUnit)operator. If an error happens inside theObservable, it will be raised as anException. If the timeout kicks in, aTimeoutExceptionnested in aRuntimeExceptionis thrown to be fully compatible with theObservable.timeout(long, TimeUnit)behavior.- Type Parameters:
T- the type returned.- Parameters:
observable- the sourceObservabletimeout- the maximum timeout before an exception is thrown.tu- the timeout unit.- Returns:
- the extracted value from the
Observableor throws in an error case.
-
-