Support chaining completed futures
The current Future.map()
implementation doesn't work on already completed futures. If you call map()
on an already completed future it doesn't return and block the program, contrary to light_map()
that works properly even on completed futures.
using Gee;
void main () {
var promise = new Promise<string>();
promise.set_value("promise?"); // the promise completed here
var future = promise.future.map<string>(value => value + " future!");
print("%s\n", future.value); // value never returned and blocks program
}
Chaining futures is an essential feature in Futures/Promises programming. This problem, however, makes it hard to use. Future.map()
should work also on already completed futures. (of course flat_map()
also)
Edited by kosmosp