Closed droundy closed 2 years ago
This has come up before in issue #4. I'm not 100% sure if it actually is threadsafe, and I don't want to introduce accidental unsafety. I did run into this issue myself, and I implemented a custom type that actually is Send + Sync (it just spawns a new thread in the background, keeps the Stream on that thread, and uses channels to communicate). That type is gated behind a feature flag: threadsafe-streams
.
I've changed my code so I no longer need Stream to be Send, but it does seem with fixing it possible. I'll ask in the coqui-stt gitter.
Never mind, I see you already asked...
It appears Stream
is Send
, but it can't be used from multiple threads at the same time, which makes the current implementation !Sync
, unless all functions that currently take &self
and access the C API were changed to take &mut self
. If you'd like to do that in your PR (#7) I'd be willing to merge that. Otherwise, I'll look into that myself at some point, and merge your PR.
It's already !Sync
, because it has a *mut
in it.
Never mind, I get it
I'm not sure how
Stream
is supposed to be used. It doesn't implementSend
. Is it really not threadsafe, or is this an oversight?