Top Description Fields Methods
io.reactivex.internal.fuseable

public Interface QueueFuseable<T>

extends SimpleQueue<T>
Known Direct Subinterfaces
io.reactivex.internal.fuseable.QueueSubscription, io.reactivex.internal.fuseable.QueueDisposable
Type Parameters
<T>
the value type returned by the SimpleQueue.poll()

Represents a SimpleQueue plus the means and constants for requesting a fusion mode.

Field Summary

Modifier and TypeField and Description
public static final int
ANY

Request any of the SYNC or ASYNC modes.

public static final int
ASYNC

Request an asynchronous fusion mode and can be returned by requestFusion(int) for an accepted mode.

public static final int
BOUNDARY

Used in binary or combination with the other constants as an input to requestFusion(int) indicating that the poll() will be called behind an asynchronous boundary and thus may change the non-trivial computation locations attached to the poll() chain of fused operators.

public static final int
NONE

Returned by the requestFusion(int) if the upstream doesn't support the requested mode.

public static final int
SYNC

Request a synchronous fusion mode and can be returned by requestFusion(int) for an accepted mode.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the established fusion mode: NONE, SYNC, ASYNC.
requestFusion
(int
the requested fusion mode, allowed values are SYNC, ASYNC, ANY combined with BOUNDARY (e.g., requestFusion(SYNC | BOUNDARY)).
mode
)

Request a fusion mode from the upstream.

Inherited from io.reactivex.internal.fuseable.SimpleQueue:
clearisEmptyofferofferpoll

Field Detail

ANYback to summary
public static final int ANY

Request any of the SYNC or ASYNC modes.

ASYNCback to summary
public static final int ASYNC

Request an asynchronous fusion mode and can be returned by requestFusion(int) for an accepted mode.

In asynchronous fusion, upstream values may become available to poll() eventually. Upstream signals onError() and onComplete() as usual but onNext may not actually contain the upstream value but have null instead. Downstream should treat such onNext as indication that poll() can be called. Note that poll() has to be called sequentially (from within a serializing drain-loop). In addition, callers of poll() should be prepared to catch exceptions.

BOUNDARYback to summary
public static final int BOUNDARY

Used in binary or combination with the other constants as an input to requestFusion(int) indicating that the poll() will be called behind an asynchronous boundary and thus may change the non-trivial computation locations attached to the poll() chain of fused operators.

For example, fusing map() and observeOn() may move the computation of the map's function over to the thread run after the observeOn(), which is generally unexpected.

NONEback to summary
public static final int NONE

Returned by the requestFusion(int) if the upstream doesn't support the requested mode.

SYNCback to summary
public static final int SYNC

Request a synchronous fusion mode and can be returned by requestFusion(int) for an accepted mode.

In synchronous fusion, all upstream values are either already available or is generated when poll() is called synchronously. When the poll() returns null, that is the indication if a terminated stream. In this mode, the upstream won't call the onXXX methods and callers of poll() should be prepared to catch exceptions. Note that poll() has to be called sequentially (from within a serializing drain-loop).

Method Detail

requestFusionback to summary
public int requestFusion(int mode)

Request a fusion mode from the upstream.

This should be called before onSubscribe returns.

Calling this method multiple times or after onSubscribe finished is not allowed and may result in undefined behavior.

Parameters
mode:int

the requested fusion mode, allowed values are SYNC, ASYNC, ANY combined with BOUNDARY (e.g., requestFusion(SYNC | BOUNDARY)).

Returns:int

the established fusion mode: NONE, SYNC, ASYNC.