Giter VIP home page Giter VIP logo

Comments (2)

kirkshoop avatar kirkshoop commented on May 24, 2024 4

current_thread is used so that multiple ranges interleave values even on a single thread. Not interleaving values can create infinite allocations inside some operators (zip is one culprit).

The create usage here is blocking in the subscribe function until the for loop completes. To get interleaving a loop cannot be used in create. Instead there must be some state and a function scheduled that sends one value and updates the state and reschedules itself.

from rxcpp.

victimsnino avatar victimsnino commented on May 24, 2024 3

Looks like it is because range observable uses scheduling under-hood via identity_current_thread instead of identity_immediate

    template<class T>
    static auto range(T first = 0, T last = std::numeric_limits<T>::max(), std::ptrdiff_t step = 1)
        -> decltype(rxs::range<T>(first, last, step, identity_current_thread())) {
        return      rxs::range<T>(first, last, step, identity_current_thread());
    }

I've expected, that second output should be "canonical", due to flat_map just subscribes on observable. In your cases both of observables are synchronized (i mean, no direct usage of threads and etc), so, subscribe should wait till on_completed. By this reason second result is correct. To have "non-serialized" output for second scenario you need to provide some scheduling manually.

@kirkshoop , what is reason to use current_thread instead of immediate for range observable?

from rxcpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.