view Implab/Promise.cs @ 243:b1e0ffdf3451 v3

working on promises
author cin
date Wed, 24 Jan 2018 19:24:10 +0300
parents 8200ab154c8a
children
line wrap: on
line source

using System;
using Implab.Parallels;

namespace Implab {
    public class Promise : AbstractPromise {
        public static readonly IPromise Success;

        static Promise() {
            Success = new SuccessPromise();
        }

        internal void ResolvePromise() {
            SetResult();
        }

        internal void RejectPromise(Exception error) {
            SetError(error);
        }

        public static IPromise Reject(Exception exception) {
            return new FailedPromise(exception);
        }
    }
}