sailfish-keyboard / sailfishos-presage-predictor

Presage based input predictor for the Sailfish OS
https://openrepos.net/content/sailfishkeyboard/maliit-plugin-presage
GNU General Public License v3.0
7 stars 4 forks source link

ASYNC implementation for Presage predicitons #20

Closed rinigus closed 6 years ago

rinigus commented 6 years ago

This PR fixes https://github.com/martonmiklos/sailfishos-presage-predictor/issues/9 by pushing predictions into separate thread.

This PR makes a separation between linking with QML in GUI thread and Presage predictor. Presage object is created in the constructor of PresagePredictor and put by it into separate thread using Presage wrapper PresageWorker. Communication between PresagePredictor and PresageWorker is implemented by queued signals allowing to perform predictions in asynchronous manner.

Here, PresagePredictor is also used as a stack which asks for new prediction and, when the worker thread is ready to do so, gives the latest request. Thus, if the worker will fall behind, it will be able to skip few predictions that are not needed anymore and perform the latest one. For this to work, language and "past buffers" are handled accordingly.

As before, RPMs are available are at https://build.merproject.org/package/show/home:rinigus:keyboard/sailfishos-presage-predictor . For ARM devices, grab http://repo.merproject.org/obs/home:/rinigus:/keyboard/sailfish_latest_armv7hl/armv7hl/maliit-plugin-presage-1.0+async.20180227153247.ab6a779-10.22.1.jolla.armv7hl.rpm and install on the top of Marisa-based RPM to get the latest version.

martonmiklos commented 6 years ago

Nice job!

rinigus commented 6 years ago

Thank you very much! It was mainly moving your code around :)