padenot / monome-rs

Talk to monome grid and arc devices in rust
Other
36 stars 2 forks source link

Support async usage ? #6

Open ssssam opened 2 years ago

ssssam commented 2 years ago

First, thanks for publishing this great library - i'm having a lot of fun making things with it.

I noticed the Monome object has only a sync API - you must have a thread that wakes up and calls poll() regularly. The internals of the library are implemented as async though, does it make sense to expose a Future directly so callers can wait for events in the system poll() function, rather than having a thread that wakes up periodically?

I am no export on async rust nor realtime app development - I would assume that there's a tradeoff with realtime performance vs power consumption that each API user would have to make when choosing between sync vs async usage.

padenot commented 2 years ago

I did it this way because usually I have a loop running a number of time per second, that updates the state (say, based on a musical clock) and draws on the device.

But I could see other types of applications, benefit from this, so we could certainly do it.