I'm having a hard time finding information as google yields results about the safety of concurrently pushing data to the subject, this isn't my use case, i have a dedicated thread (running an infinite loop) producing data, and i want N other threads to be able to subscribe to it.
Is it safe to call non-producing methods (subsribe/observe etc but not On*) methods on a Subject from another thread than the one who created it if i only push data into it from a single (who also happens to be the instance creating) thread?
In the case it is safe : is it safe at any time (could i subscribe from another thread while the primary one is in the middle on calling OnNext) or is it only safe if when i call Subscribe no data is being produced?
Same question as #2 but about multiple observers calling Subscribe at the same time to register if i have a dozen threads that need to register, is that also safe?
Yes, these methods are thread safe. I don't think there is explicit documentation to that effect, but the most compelling, if not easily digestible evidence is the source code itself.
Take a look at the implementation of Subscribe here to see plenty of evidence of use of thread safe techniques, such as use of Interlocked
when updating the observers.
To avoid misleading any casual readers, I reiterate your observation that OnNext
etc. methods are not thread safe by design, and use of the Synchronize
method can help there if you really need them to be.