Mercurial > pub > ImplabNet
annotate Implab/IPromise.cs @ 200:71e543dbe65a v2
working version of the project
author | cin |
---|---|
date | Fri, 14 Oct 2016 04:03:10 +0300 |
parents | ec91a6dfa5b3 |
children | cbe10ac0731e |
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> | |
12 Type PromiseType { get; } | |
25 | 13 |
74 | 14 /// <summary> |
99 | 15 /// Обещание является выполненым, либо успешно, либо с ошибкой, либо отменено. |
74 | 16 /// </summary> |
66 | 17 bool IsResolved { get; } |
18 | |
74 | 19 /// <summary> |
20 /// Обещание было отменено. | |
21 /// </summary> | |
66 | 22 bool IsCancelled { get; } |
25 | 23 |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
24 /// <summary> |
138
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
25 /// Исключение возникшее в результате выполнения обещания, либо причина отмены. |
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
26 /// </summary> |
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
27 Exception Error { get; } |
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
28 |
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
29 /// <summary> |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
30 /// Adds specified listeners to the current promise. |
75 | 31 /// </summary> |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
32 /// <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
|
33 /// <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
|
34 /// <param name="cancel">The handler is called in case of promise cancellation.</param> |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
35 /// <returns>The current promise.</returns> |
138
f75cfa58e3d4
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents:
119
diff
changeset
|
36 IPromise On(Action success, Action<Exception> error, Action<Exception> cancel); |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
37 IPromise On(Action success, Action<Exception> error); |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
38 IPromise On(Action success); |
75 | 39 |
74 | 40 /// <summary> |
119
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
41 /// Adds specified listeners to the current promise. |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
42 /// </summary> |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
43 /// <param name="handler">The handler called on the specified events.</param> |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
44 /// <param name = "events">The combination of flags denoting the events for which the |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
45 /// handler shoud be called.</param> |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
46 /// <returns>The current promise.</returns> |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
47 IPromise On(Action handler, PromiseEventType events); |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
48 |
2573b562e328
Promises rewritten, added improved version of AsyncQueue
cin
parents:
104
diff
changeset
|
49 /// <summary> |
74 | 50 /// Преобразует результат обещания к заданному типу и возвращает новое обещание. |
51 /// </summary> | |
66 | 52 IPromise<T> Cast<T>(); |
26 | 53 |
74 | 54 /// <summary> |
55 /// Синхронизирует текущий поток с обещанием. | |
56 /// </summary> | |
66 | 57 void Join(); |
74 | 58 /// <summary> |
59 /// Синхронизирует текущий поток с обещанием. | |
60 /// </summary> | |
61 /// <param name="timeout">Время ожидания, по его истечению возникнет исключение.</param> | |
62 /// <exception cref="TimeoutException">Превышено время ожидания.</exception> | |
66 | 63 void Join(int timeout); |
7 | 64 |
65 } | |
66 } |