Closed georgemorgan closed 7 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?
Got 'em.
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.