simonvetter / modbus

Go modbus stack (client and server)
MIT License
262 stars 83 forks source link

Concurrent calls to client #2

Closed maddie closed 4 years ago

maddie commented 4 years ago

Is it safe to call client.Read* methods concurrently?

simonvetter commented 4 years ago

yes, the client API is thread-safe: all exported methods acquire a mutex at some point.

See https://github.com/simonvetter/modbus/blob/master/client.go#L796 and https://github.com/simonvetter/modbus/blob/master/client.go#L706 for reads. Writes and other methods should all do something similar.

Let me know if you run into any concurrency issue as that would definitely be a bug.

maddie commented 4 years ago

Good to know, thanks a lot!