Mercurial > pub > ImplabNet
comparison Implab/IPromise.cs @ 192:f1da3afc3521 release v2.1
Слияние с v2
| author | cin | 
|---|---|
| date | Fri, 22 Apr 2016 13:10:34 +0300 | 
| parents | ec91a6dfa5b3 | 
| children | cbe10ac0731e | 
   comparison
  equal
  deleted
  inserted
  replaced
| 71:1714fd8678ef | 192:f1da3afc3521 | 
|---|---|
| 3 using System.Linq; | 3 using System.Linq; | 
| 4 using System.Text; | 4 using System.Text; | 
| 5 | 5 | 
| 6 namespace Implab { | 6 namespace Implab { | 
| 7 public interface IPromise: ICancellable { | 7 public interface IPromise: ICancellable { | 
| 8 /// <summary> | |
| 9 /// Check whereather the promise has no more than one dependent promise. | |
| 10 /// </summary> | |
| 11 bool IsExclusive { | |
| 12 get; | |
| 13 } | |
| 14 | 8 | 
| 15 /// <summary> | 9 /// <summary> | 
| 16 /// Тип результата, получаемого через данное обещание. | 10 /// Тип результата, получаемого через данное обещание. | 
| 17 /// </summary> | 11 /// </summary> | 
| 18 Type PromiseType { get; } | 12 Type PromiseType { get; } | 
| 19 | 13 | 
| 14 /// <summary> | |
| 15 /// Обещание является выполненым, либо успешно, либо с ошибкой, либо отменено. | |
| 16 /// </summary> | |
| 20 bool IsResolved { get; } | 17 bool IsResolved { get; } | 
| 21 | 18 | 
| 19 /// <summary> | |
| 20 /// Обещание было отменено. | |
| 21 /// </summary> | |
| 22 bool IsCancelled { get; } | 22 bool IsCancelled { get; } | 
| 23 | 23 | 
| 24 IPromise Then(Action success,ErrorHandler error); | 24 /// <summary> | 
| 25 IPromise Then(Action success); | 25 /// Исключение возникшее в результате выполнения обещания, либо причина отмены. | 
| 26 IPromise Error(ErrorHandler error); | 26 /// </summary> | 
| 27 IPromise Anyway(Action handler); | 27 Exception Error { get; } | 
| 28 IPromise Finally(Action handler); | |
| 29 IPromise Cancelled(Action handler); | |
| 30 | 28 | 
| 29 /// <summary> | |
| 30 /// Adds specified listeners to the current promise. | |
| 31 /// </summary> | |
| 32 /// <param name="success">The handler called on the successful promise completion.</param> | |
| 33 /// <param name="error">The handler is called if an error while completing the promise occurred.</param> | |
| 34 /// <param name="cancel">The handler is called in case of promise cancellation.</param> | |
| 35 /// <returns>The current promise.</returns> | |
| 36 IPromise On(Action success, Action<Exception> error, Action<Exception> cancel); | |
| 37 IPromise On(Action success, Action<Exception> error); | |
| 38 IPromise On(Action success); | |
| 39 | |
| 40 /// <summary> | |
| 41 /// Adds specified listeners to the current promise. | |
| 42 /// </summary> | |
| 43 /// <param name="handler">The handler called on the specified events.</param> | |
| 44 /// <param name = "events">The combination of flags denoting the events for which the | |
| 45 /// handler shoud be called.</param> | |
| 46 /// <returns>The current promise.</returns> | |
| 47 IPromise On(Action handler, PromiseEventType events); | |
| 48 | |
| 49 /// <summary> | |
| 50 /// Преобразует результат обещания к заданному типу и возвращает новое обещание. | |
| 51 /// </summary> | |
| 31 IPromise<T> Cast<T>(); | 52 IPromise<T> Cast<T>(); | 
| 32 | 53 | 
| 54 /// <summary> | |
| 55 /// Синхронизирует текущий поток с обещанием. | |
| 56 /// </summary> | |
| 33 void Join(); | 57 void Join(); | 
| 58 /// <summary> | |
| 59 /// Синхронизирует текущий поток с обещанием. | |
| 60 /// </summary> | |
| 61 /// <param name="timeout">Время ожидания, по его истечению возникнет исключение.</param> | |
| 62 /// <exception cref="TimeoutException">Превышено время ожидания.</exception> | |
| 34 void Join(int timeout); | 63 void Join(int timeout); | 
| 35 | 64 | 
| 36 } | 65 } | 
| 37 } | 66 } | 
