You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Flow implements operator fusion for operators that rely on channels. E.g., if you start with an RxJava2 Flowable, and then do:
val subscriptionChannel = myFlowable
.flowOn(Dispatchers.IO) // Subscribe/observe on a background thread.
.buffer(50) // Buffer up to 50 items when there's backpressure.
.produceIn(scope) // Subscribe to the Flowable with a ReceiveChannel.
Then only a single channel will be created and shared between all the operators to own the subscription to the Flowable, communicate between threads, and store the buffer. And that same channel will be what is returned from produceIn. This is just an optimization, since each of those declarative operators describe a different aspect of channels' behavior. If you put another, non-channel operator between any of those operators, two separate channels will be created. The behavior of the Flow shouldn't change, but it will use a bit more memory.
The Workflow runtime uses channels to subscribe to Workers. In practice, at least for now, many workers are likely to be direct wrappers around other reactive stream types. So while we can't force Workers to use operator fusion (nor would we want to), we should at least not prevent fusion from occurring when possible.
Currently, to keep the change to using Flow for the Worker API simple, call map just before produceIn in order to wrap values in the Output sentinel type. This prevents any operator fusion from ever occurring in the common case of, for example myObservable.asWorker(). We should remove that map to allow fusion to occur.
The text was updated successfully, but these errors were encountered:
Flow implements operator fusion for operators that rely on channels. E.g., if you start with an RxJava2
Flowable
, and then do:Then only a single channel will be created and shared between all the operators to own the subscription to the
Flowable
, communicate between threads, and store the buffer. And that same channel will be what is returned fromproduceIn
. This is just an optimization, since each of those declarative operators describe a different aspect of channels' behavior. If you put another, non-channel operator between any of those operators, two separate channels will be created. The behavior of theFlow
shouldn't change, but it will use a bit more memory.The Workflow runtime uses channels to subscribe to Workers. In practice, at least for now, many workers are likely to be direct wrappers around other reactive stream types. So while we can't force Workers to use operator fusion (nor would we want to), we should at least not prevent fusion from occurring when possible.
Currently, to keep the change to using Flow for the Worker API simple, call
map
just beforeproduceIn
in order to wrap values in theOutput
sentinel type. This prevents any operator fusion from ever occurring in the common case of, for examplemyObservable.asWorker()
. We should remove that map to allow fusion to occur.The text was updated successfully, but these errors were encountered: