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.
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.