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