tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
604 stars 188 forks source link

wifinina: add mutex to prevent communication race problems #414

Closed deadprogram closed 2 years ago

deadprogram commented 2 years ago

This PR adds a mutex to the WifiNINA driver to prevent communication race problems when multiple goroutines try to access adaptor at the same time.

ysoldak commented 2 years ago

Why don’t put mutex on all public methods? Basically any “concurrent” access to wifinina upsets communication. Like one goroutune does networking, another does RGB leds…

deadprogram commented 2 years ago

@ysoldak I tried to only use the mutex where it seemed absolutely needed. Are there any specific functions you think I should cover that I missed, or is this more of a general comment?

ysoldak commented 2 years ago

@deadprogram general comment, yes.

deadprogram commented 2 years ago

That being the case, I will merge this and then further improvements can continue from there. Thanks @ysoldak