Exemplo n.º 1
0
        public static Future <A> async(out Promise <A> promise)
        {
            var impl = new FutureImpl <A>();

            promise = impl;
            return(new Future <A>(new OneOf <A, UnfulfilledFuture, IHeapFuture <A> >(impl)));
        }
Exemplo n.º 2
0
        public Future <B> map <B>(Fn <A, B> mapper)
        {
            var p = new FutureImpl <B>();

            onComplete(v => p.complete(mapper(v)));
            return(p);
        }
Exemplo n.º 3
0
        public Future <B> flatMap <B>(Fn <A, Future <B> > mapper)
        {
            var p = new FutureImpl <B>();

            onComplete(v => mapper(v).onComplete(p.complete));
            return(p);
        }
Exemplo n.º 4
0
        public static Future <A> StartCoroutine <A>(
            Func <Promise <A>, IEnumerator> coroutine
            )
        {
            var f = new FutureImpl <A>();

            behaviour.StartCoroutine(coroutine(f));
            return(f);
        }