Skip to content

Question about the coordinator in sources and why it causes segfault #579

@wuyuanyi135

Description

@wuyuanyi135

I have the following code that crashes. It is a RX subscription that is supposed to iterate data sequentially (Here it is not substantial but if I introduce delay after just it will be the case).

I understand how a scheduler (coordinator) works for a deferred operation (like delay) but I don't know what is the point to supply the coordinator to the sources (such as just or iterate). I simply put the same coordinator to every rx function that takes the coordinator but in this case apparently it fails. I found that if I remove the coordinator in just it will run correctly.

I wonder why shouldn't I use the coordinator in this case and when should I use it?

  schedulers::run_loop rl;
  identity_one_worker c(schedulers::make_run_loop(rl));
  sources::iterate(data, c)
      .concat_map(
          [&](int v) {
            return sources::just(v, c);
          },
          c)
      .subscribe([](int v) {
        std::cout << "Next " << v << "\n";
      });

  while (true) {
    rl.dispatch();
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions