Please see title. I’d expect they are, meaning I can share the materialized Source and Sink around as much as I want among actors etc, but I haven’t found any explicit documentation or Q&A on this.
I looked into the code of MergeHub
, and it uses a thread-safe queue that is shared among all Sink
materializations. So it’s thread-safe. BroadcastHub
has a lot more complex mechanisms based on volatile variables and simple Arrays, but it’s apparent that it is meant to be used in a multi-threaded context as well.
Yes, you should expect to be able to share those across threads (for example materializing an up or downstream per incoming HTTP connection or in response to messages to an actor)
MergeHub
turns out to be surprisingly fast too in my micro-benchmarks, with throughput similar to a java.util.concurrent.LinkedBlockingQueue
. Only slightly slower (maybe half), when emitting millions of elements per second concurrently from multiple threads. Small price for the flexibility that you get.