BitBoxSwiss / bitbox-api-rs

BitBox02 client library for Rust and TypeScript
Apache License 2.0
5 stars 9 forks source link

allow for multithreaded use of PairingBitBox and PairedBitBox #19

Closed benma closed 1 year ago

benma commented 1 year ago

Generally, the hidapi based communication should be single-threaded, as on macOS, we have seen communication issues when the hidapi calls move between threads. See https://github.com/libusb/hidapi/issues/503.

The above issue is unresolved and unexplained, and might only happen in combination with the Go runtime, Nevertheless, it is safer to use it only single-threaded, to avoid potential issues.

This commit enables Sync+Send (multithreading) by activating the "multithreaded" feature for when multithreading is required. Sync/Send cannot be activated in WASM as the function pointers in JsReadWrite do not implement Sync/Send.