ReactiveX / RxCpp

Reactive Extensions for C++
Apache License 2.0
3.05k stars 395 forks source link

Question about coordination #434

Closed nikobarli closed 6 years ago

nikobarli commented 6 years ago

Hi,

I am trying to understand the different types of coordination in the current rxcpp by reading https://github.com/Reactive-Extensions/RxCpp/blob/master/DeveloperManual.md, but I don't quite understand yet the difference between between:

rxcpp::observeon*

and

rxcpp::serialize_*

When should I use observeon and when should I use serialize_ ?

thanks.

kirkshoop commented 6 years ago

Hi!

These are both coordinators that are layered on top of schedulers. The operators offload thread-safe coordination to these coordinators. in the case of merge, each incoming observable is passed through the coordinator to get a coordinated observable that shares a context.

the observe_on coordinator uses a shared queue and the layered scheduler to transport work to a single destination thread.

serialize coordinator uses a shared mutex to serialize calls to on_next, on_error, on_completed and to the scheduled items on the layered scheduler.

Does this help?