GithubHelp home page GithubHelp logo

Deprecate ImmediateScheduler? about rxphp HOT 4 CLOSED

reactivex avatar reactivex commented on May 22, 2024
Deprecate ImmediateScheduler?

from rxphp.

Comments (4)

davidwdan avatar davidwdan commented on May 22, 2024 1

I'm going to close this issue. Even if you default to an async scheduler, we'll still need the immediate scheduler for some functional tests.

from rxphp.

Ocramius avatar Ocramius commented on May 22, 2024

This occasionally blows out the stack

With XDebug or just infinite stack => segfault?

some operators won't work at all.

Is there an example, or a reference of this?

The ImmediateScheduler mostly seems to exist because it was easy to run small demos with it when the project was still young. It's unusable for anything serious. Should we:

Those small demos are still kinda required. What is the alternative approach?

from rxphp.

davidwdan avatar davidwdan commented on May 22, 2024

Here's an example that will give the wrong output and then segfault:

$o1 = Rx\Observable::just(42)->repeat();
$o2 = Rx\Observable::just(21)->repeat();

$mergedObservable = $o1
    ->merge($o2)
    ->take(10);

output:

Next value: 42
Next value: 42
Next value: 42
Next value: 42
Next value: 42
Next value: 42
Next value: 42
Next value: 42
Next value: 42
Next value: 42
Complete!
[1]    59785 segmentation fault ...

expected output:

Next value: 42
Next value: 21
Next value: 42
Next value: 21
Next value: 42
Next value: 21
Next value: 42
Next value: 21
Next value: 42
Next value: 21
Complete!

from rxphp.

mbonneau avatar mbonneau commented on May 22, 2024

As I see it - the pros and cons of the ImmediateScheduler are:

Pros:

  • Can write simple demos for some of the operators.
  • Requires no boilerplate code for the things that work with it.
  • You don't need an event loop.

Cons:

  • Most test cases use a scheduler that actually schedules items, so almost all test cases are not valid for the ImmediateScheduler.
  • Execution ordering can be different with the ImmediateScheduler than with others.
  • ImmediateScheduler has a tendency to blow the stack.
  • Cannot do anything that requires timing (interval, timeout, delay, etc.).

I would prefer that we move away from the ImmediateScheduler. This would mean that the barrier to entry would be a tiny bit higher in that people will at the very minimum need to start a loop or scheduler (unless we make a scheduler that autostarts either on subscribe or at the end of execution).

It is possible to make a really simple scheduler that just uses sleep if we wanted the bare minimum scheduler - but that would still require a start.

from rxphp.

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.