pezi / dart_periphery

dart_periphery is a Dart port of the native c-periphery library
BSD 3-Clause "New" or "Revised" License
40 stars 12 forks source link

Question about sync API #23

Open ookami-kb opened 1 year ago

ookami-kb commented 1 year ago

Is there any specific reason why all the API is sync and waiting is implemented with sleep instead of await?

I'm using the library with flutter-pi and for some reason, it doesn't work great with isolates. The library calls sleep throughout the code, making UI laggy.

pezi commented 8 months ago

I know, the lack of an isolates integration is a problem for flutter-pi. I am Java developer, and thinking like a Java developer a created a helper class to integrate isolation with help of reflection and annotation some time ago

https://github.com/pezi/dart_periphery/blob/ps/0.9.4_isolate_api/lib/src/isolate_helper.dart

But this approach was a hasty action. dart:mirrors doesn't support AOT - therefore no flutter support. This code works only inside CLI based app.

Integreation isolate code by hand works. The only way to add isolate support for this project is to uses code generators like source_gen. In the next time I will do this step.

pezi commented 4 months ago

New subproject which handles isolates is available https://github.com/pezi/flutter-pi-sensor-tester