*/
internal class Gee.FlatMapFuture<A, G> : Object, Future<A> {
- public FlatMapFuture (Future<G> base_future, Future.FlatMapFunc<A, G> func) {
+ public FlatMapFuture (Future<G> base_future, owned Future.FlatMapFunc<A, G> func) {
_base = base_future;
- _func = func;
+ _func = (owned)func;
_base.when_done ((val) => {
_mutex.lock ();
if (_progress == Progress.INIT) {
assert_not_reached ();
}
- public void when_done (Future.WhenDoneFunc<A> func) {
+ public void when_done (owned Future.WhenDoneFunc<A> func) {
_mutex.lock ();
if (_progress == Progress.READY) {
_mutex.unlock ();
* future it is recommended to not include lengthly computation.
* If one is needed please use {@link task}.
*/
- public abstract void when_done (WhenDoneFunc<G> func);
+ public abstract void when_done (owned WhenDoneFunc<G> func);
public delegate A MapFunc<A, G> (G value);
* value eagerly by {@link when_done} it is recommended to use
* {@link task} and {@link flat_map} for longer computation.
*/
- public virtual Future<A> map<A> (MapFunc<A, G> func) {
- return new MapFuture<A, G> (this, func);
+ public virtual Future<A> map<A> (owned MapFunc<A, G> func) {
+ return new MapFuture<A, G> (this, (owned)func);
}
public delegate unowned A LightMapFunc<A, G> (G value);
* value eagerly by {@link when_done} it is recommended to return a
* future from {@link task} and use {@link flat_map} for longer computation.
*/
- public virtual Future<B> zip<A, B> (ZipFunc<G, A, B> zip_func, Future<A> second) {
- return new ZipFuture<G, A, B> (zip_func, this, second);
+ public virtual Future<B> zip<A, B> (owned ZipFunc<G, A, B> zip_func, Future<A> second) {
+ return new ZipFuture<G, A, B> ((owned)zip_func, this, second);
}
[CCode (scope = "async")]
* larger computation inside the returned future for example by
* {@link task}
*/
- public virtual Gee.Future<A> flat_map<A>(FlatMapFunc<A, G> func) {
- return new FlatMapFuture<A, G> (this, func);
+ public virtual Gee.Future<A> flat_map<A>(owned FlatMapFunc<A, G> func) {
+ return new FlatMapFuture<A, G> (this, (owned)func);
}
internal struct WhenDoneArrayElement<G> {
- public WhenDoneArrayElement (WhenDoneFunc<G> func) {
- this.func = func;
+ public WhenDoneArrayElement (owned WhenDoneFunc<G> func) {
+ this.func = (owned)func;
}
public WhenDoneFunc<G> func;
}
*/
internal class Gee.MapFuture<A, G> : Object, Future<A> {
- public MapFuture (Future<G> future_base, Future.MapFunc<A, G> func) {
+ public MapFuture (Future<G> future_base, owned Future.MapFunc<A, G> func) {
_base = future_base;
- _func = func;
+ _func = (owned)func;
_base.when_done ((val) => {
_mutex.lock ();
if (_progress == Progress.INIT) {
assert_not_reached ();
}
- public void when_done (Future.WhenDoneFunc<A> func) {
+ public void when_done (owned Future.WhenDoneFunc<A> func) {
_mutex.lock ();
if (_progress == Progress.READY) {
_mutex.unlock ();
func (_value);
} else {
- _when_done += Future.WhenDoneArrayElement<G>(func);
+ _when_done += Future.WhenDoneArrayElement<G>((owned)func);
_mutex.unlock ();
}
}
*/
internal class Gee.ZipFuture<A, B, C> : GLib.Object, Gee.Future<C> {
- public ZipFuture (Future.ZipFunc<A, B, C> func, Future<A> left, Future<B> right) {
+ public ZipFuture (owned Future.ZipFunc<A, B, C> func, Future<A> left, Future<B> right) {
_left = left;
_right = right;
- _func = func;
+ _func = (owned)func;
_left.when_done ((l) => {
_right.when_done ((r) => {
_mutex.lock ();
assert_not_reached ();
}
- public void when_done (Future.WhenDoneFunc<C> func) {
+ public void when_done (owned Future.WhenDoneFunc<C> func) {
_mutex.lock ();
if (_progress == Progress.READY) {
_mutex.unlock ();