Mercurial > pub > ImplabNet
annotate Implab/IPromise.cs @ 242:cbe10ac0731e v3
Working on promises
author | cin |
---|---|
date | Wed, 24 Jan 2018 03:03:21 +0300 |
parents | ec91a6dfa5b3 |
children | b1e0ffdf3451 |
rev | line source |
---|---|
7 | 1 using System; |
2 using System.Collections.Generic; | |
3 using System.Linq; | |
4 using System.Text; | |
5 | |
66 | 6 namespace Implab { |
7 public interface IPromise: ICancellable { | |
26 | 8 |
66 | 9 /// <summary> |
10 /// Тип результата, получаемого через данное обещание. | |
11 /// </summary> | |
242 | 12 Type ResultType { get; } |
25 | 13 |
74 | 14 /// <summary> |
99 | 15 /// Обещание является выполненым, либо успешно, либо с ошибкой, либо отменено. |
74 | 16 /// </summary> |
242 | 17 bool IsFulfilled { get; } |
66 | 18 |
242 | 19 bool IsRejected { get; } |
20 | |
21 bool IsResolved { get; } | |
25 | 22 |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
23 /// <summary> |
138
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
24 /// Исключение возникшее в результате выполнения обещания, либо причина отмены. |
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
25 /// </summary> |
242 | 26 Exception RejectReason { get; } |
138
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
27 |
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
28 /// <summary> |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
29 /// Adds specified listeners to the current promise. |
75 | 30 /// </summary> |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
31 /// <param name="success">The handler called on the successful promise completion.</param> |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
32 /// <param name="error">The handler is called if an error while completing the promise occurred.</param> |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
33 /// <returns>The current promise.</returns> |
242 | 34 void On(Action success, Action<Exception> error); |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
35 |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
36 /// <summary> |
74 | 37 /// Преобразует результат обещания к заданному типу и возвращает новое обещание. |
38 /// </summary> | |
66 | 39 IPromise<T> Cast<T>(); |
26 | 40 |
74 | 41 /// <summary> |
42 /// Синхронизирует текущий поток с обещанием. | |
43 /// </summary> | |
66 | 44 void Join(); |
74 | 45 /// <summary> |
46 /// Синхронизирует текущий поток с обещанием. | |
47 /// </summary> | |
48 /// <param name="timeout">Время ожидания, по его истечению возникнет исключение.</param> | |
49 /// <exception cref="TimeoutException">Превышено время ожидания.</exception> | |
66 | 50 void Join(int timeout); |
7 | 51 |
52 } | |
53 } |