mnetship / ratsio

NATS & NATS Streaming Server client library for Rust
MIT License
50 stars 22 forks source link

Sync and Async/Await #12

Open dbcfd opened 4 years ago

dbcfd commented 4 years ago

Async/Await code should use an async concurrency primitive (e.g. tokio::sync::RwLock).

Non async primitives will produce errors like

`std::sync::RwLockReadGuard<'_, ratsio::stan_client::ClientInfo>` cannot be sent between threads safely

Additionally, since they do not wake the executor, they can cause threads in the executor to enter infinite wait states.

giacomocariello commented 4 years ago

dbcfd seems to fix the issue successfully. Could @mnetship please accept the PR and possibly publish a new release on crates.io?

ebkalderon commented 4 years ago

I'm glad that there already exists a pull request which switches from blocking std::sync::RwLock to non-blocking tokio::sync::Mutex. I was about to open an issue and PR to fix this myself. Nice to see someone else got to it first! It's a big blocker for me using this library. 😄