Promise.cs
25 lines
| 544 B
| text/x-csharp
|
CSharpLexer
/ Implab / Promise.cs
cin
|
r119 | using System; | ||
cin
|
r144 | using Implab.Parallels; | ||
cin
|
r119 | |||
namespace Implab { | ||||
cin
|
r144 | public class Promise : AbstractPromise, IDeferred { | ||
cin
|
r205 | public static readonly IPromise Success; | ||
cin
|
r119 | |||
cin
|
r144 | static Promise() { | ||
cin
|
r205 | Success = new SuccessPromise(); | ||
cin
|
r119 | } | ||
public void Resolve() { | ||||
cin
|
r144 | SetResult(); | ||
cin
|
r119 | } | ||
public void Reject(Exception error) { | ||||
SetError(error); | ||||
cin
|
r205 | } | ||
public static IPromise FromException(Exception exception) { | ||||
return new FailedPromise(exception); | ||||
} | ||||
cin
|
r119 | } | ||
} | ||||