flipper-io / flipper

Flipper is a development platform that can be controlled from any programming language.
https://www.flipper.io/
Apache License 2.0
70 stars 15 forks source link

Feature: lf_wait #48

Closed georgemorgan closed 7 years ago

georgemorgan commented 8 years ago

I propose implementing an official libflipper function called lf_wait that performs a thread delay for the specified number of milliseconds to ensure that variable time operations are allowed to complete on the device before libflipper officially attempts to request a return value. Currently, we rely on the USB driver to block IO operations, but the operating system times out for requests lasting longer than a few seconds (it varies). It would be much better to synchronize operations ourselves to ensure that operations be suspended long enough so as to let the device finish its asynchronous operations without interruption from the host.

TravisWhitaker commented 8 years ago

What's wrong with usleep()?

Additionally, it is very unfriendly to language bindings to have libflipper functions put the calling thread to sleep. I guess I wasn't aware that libflipper actually explicitly requests the return value. Why can it just block (or spinlock if necessary) until the device returns something?

georgemorgan commented 7 years ago

Got 'em.