Skip to content

ElementAt backpressure improvements #3014

Closed
@akarnokd

Description

@akarnokd

The operator elementAt could be improved in several ways:

  • It could request index amount upfront so it doesn't have to request(1) at every skipped value
    • this could be achieved with unconditional requesting in onStart() + SingleDelayedProducer or conditionally when the child subscriber actually requests a positive value(i.e., if (n > 0 && once.compareAndSet(false, true)) request(index))
  • Once the required element arrives, one should call this.unsubscribe() in onNext().
    • Note that the parent subscriber can't directly wrap the child subscriber anymore.
  • I'd also do a currentIndex < index check in onError in case an error happens after the indexth element and it slips through.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions