What is an example of unintended consequences arising from Observable.merge<'T> not being thread safe?

StackOverflow https://stackoverflow.com/questions/18703952

  •  28-06-2022
  •  | 
  •  

Вопрос

The documentation states:

"For each observer, the registered intermediate observing object is not thread safe. That is, observations arising from the sources must not be triggered concurrently on different threads."

This also applies to Observable.pairwise<'T> and Observable.scan<'U,'T>.

What is an example of Observable.merge being used in a manner that produces unintended consequences given that it is not thread-safe?

Это было полезно?

Решение

Based on the source code, it looks like if the observerables were both to fire OnCompleted on different threads, then it's possible that the merged observable would fail to complete.

Другие советы

Generally speaking, thread-safe indicates that using functionality from different threads won't result in race-conditions or deadlocks. In this particular case, I'm going to guess that observations might overwrite each other or otherwise interleave execution in a way which might cause a crash or other unstable states.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top