Publisher is !Send #546
-
That prevent sending from multi-thread. For example binding to python with pyo3, which demands the object to be Send + Sync. We can’t turn !Send to Send even with protection. Using channel won’t possible also, the loaned Sample is !Send so can’t travel to other thread. The only possible way I can think about is send Vec and copy to loaned Sample, that isn’t zero copy anymore. Is there any reason that makes Publisher truly !Send? I think local-only is good and my system also could be single threaded. But, pyo3 don’t like that idea. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, there is. The We are aware of the issue and will soon provide |
Beta Was this translation helpful? Give feedback.
@yakiro-nvg
Yes, there is. The
SampleMut
calls internal non-threadsafe constructs in the publisher when it goes out-of-scope or callsSampleMut::send()
. If the sample were moved into a different thread and went out-of-scope there, it would cause a race condition inside thePublisher
.We are aware of the issue and will soon provide
PublisherTs
andSubscriberTs
ports that are completely threadsafe and could then be used in a Python binding - here, you would pay a little extra for an additional mutex. The samples would then also come with such a variant.