Merge: Intro `Task` and use in for Android's `run_on_ui_thread`
authorJean Privat <jean@pryen.org>
Thu, 5 Nov 2015 15:13:53 +0000 (10:13 -0500)
committerJean Privat <jean@pryen.org>
Thu, 5 Nov 2015 15:13:53 +0000 (10:13 -0500)
commit536a3ff9e45fa7b1abb3a2ffa0f22fd1e818db81
treee239941aeef87faaf5186ee0c069a40c6bd5d128
parentaa7b441eeed93caa92a681453d5eb69062789d9a
parent6bbbd860a81f70cb15cd110c363d8a313e7a26e4
Merge: Intro `Task` and use in for Android's `run_on_ui_thread`

The `Task` interface defines a fragment of Nit code to execute in its `main` method. This interface should be compatible between different platforms and parallelization engines.

`NativeActivity::run_on_ui_thread` is widely used on Android as most logic is executed on background threads but only the UI thread can modify the UI. It is a perfect example of how the `Task` interface can be used.

Future work include using `Task` in `pthreads` and `gtk::gdk`. But there a a few differences in the logic that makes it not as easy: `Thread::main` returns a `nullable object`, but is it worth keeping it? `GdkRunnable::run` returns a boolean to tell GDK if it should be called again.

Pull-Request: #1812
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>