annotate Implab/IPromise.cs @ 141:0fa293bb1351 v2

fixed JSON writer
author cin
date Tue, 24 Feb 2015 00:54:22 +0300
parents f75cfa58e3d4
children 8c0b95069066
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
7ea9363fef6c inital progress handling
cin
parents:
diff changeset
1 using System;
7ea9363fef6c inital progress handling
cin
parents:
diff changeset
2 using System.Collections.Generic;
7ea9363fef6c inital progress handling
cin
parents:
diff changeset
3 using System.Linq;
7ea9363fef6c inital progress handling
cin
parents:
diff changeset
4 using System.Text;
7ea9363fef6c inital progress handling
cin
parents:
diff changeset
5
66
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
6 namespace Implab {
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
7 public interface IPromise: ICancellable {
26
f0bf98e4d22c refactoring
cin
parents: 25
diff changeset
8
66
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
9 /// <summary>
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
10 /// Тип результата, получаемого через данное обещание.
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
11 /// </summary>
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
12 Type PromiseType { get; }
25
9bf5b23650c9 refactoring
cin
parents: 19
diff changeset
13
74
c4140283575c minor fixes
cin
parents: 66
diff changeset
14 /// <summary>
99
8ddf1648eca4 fixed TransientPromiseException handling
cin
parents: 96
diff changeset
15 /// Обещание является выполненым, либо успешно, либо с ошибкой, либо отменено.
74
c4140283575c minor fixes
cin
parents: 66
diff changeset
16 /// </summary>
66
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
17 bool IsResolved { get; }
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
18
74
c4140283575c minor fixes
cin
parents: 66
diff changeset
19 /// <summary>
c4140283575c minor fixes
cin
parents: 66
diff changeset
20 /// Обещание было отменено.
c4140283575c minor fixes
cin
parents: 66
diff changeset
21 /// </summary>
66
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
22 bool IsCancelled { get; }
25
9bf5b23650c9 refactoring
cin
parents: 19
diff changeset
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 /// Creates a new promise dependend on the current one and resolved on
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
31 /// executing the specified handlers.
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
32 /// </summary>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
33 /// <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
34 /// <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
35 /// <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
36 /// <returns>The newly created dependant promise.</returns>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
37 /// <remarks>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
38 /// <para>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
39 /// If the success handler is specified the dependend promise will be resolved after the handler is
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
40 /// executed and the dependent promise will be linked to the current one, i.e. the cancellation
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
41 /// of the dependent property will lead to the cancellation of the current promise. If the
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
42 /// success handler isn't specified the dependent promise will not be linked to and
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
43 /// will not be resolved after the successfull resolution of the current one.
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
44 /// </para>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
45 /// <para>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
46 /// When the error handler is specified, the exception raised during the current promise completion
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
47 /// will be passed to it as the parameter. If the error handler returns without raising an
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
48 /// exception then the dependant promise will be resolved successfully, otherwise the exception
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
49 /// raised by the handler will be transmitted to the dependent promise. If the handler wants
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
50 /// to passthrough the original exception it needs to wrap the exception with
138
f75cfa58e3d4 added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents: 119
diff changeset
51 /// the <see cref="PromiseTransientException"/>. The handler may raise <see cref="OperationCanceledException"/>
f75cfa58e3d4 added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents: 119
diff changeset
52 /// to cancel the dependant promise, the innner exception specifies the reason why the promise
f75cfa58e3d4 added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents: 119
diff changeset
53 /// is canceled.
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
54 /// </para>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
55 /// <para>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
56 /// If the cancelation handler is specified and the current promise is cancelled then the dependent
138
f75cfa58e3d4 added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents: 119
diff changeset
57 /// promise will be resolved after the handler is executed. If the cancelation handler raises the
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
58 /// exception it will be passed to the dependent promise.
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
59 /// </para>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
60 /// </remarks>
138
f75cfa58e3d4 added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents: 119
diff changeset
61 IPromise Then(Action success, Action<Exception> error, Action<Exception> cancel);
101
279e226dffdd code cleanup
cin
parents: 99
diff changeset
62 IPromise Then(Action success, Action<Exception> error);
66
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
63 IPromise Then(Action success);
75
4439140706d0 major refactoring, added tasks support
cin
parents: 74
diff changeset
64
138
f75cfa58e3d4 added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents: 119
diff changeset
65 IPromise Chain(Func<IPromise> chained, Func<Exception, IPromise> error, Func<Exception, IPromise> cancel);
101
279e226dffdd code cleanup
cin
parents: 99
diff changeset
66 IPromise Chain(Func<IPromise> chained, Func<Exception, IPromise> error);
96
daffa72a1cec Added the chaining method to the non-generic IPromise
cin
parents: 76
diff changeset
67 IPromise Chain(Func<IPromise> chained);
daffa72a1cec Added the chaining method to the non-generic IPromise
cin
parents: 76
diff changeset
68
75
4439140706d0 major refactoring, added tasks support
cin
parents: 74
diff changeset
69 /// <summary>
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
70 /// Adds specified listeners to the current promise.
75
4439140706d0 major refactoring, added tasks support
cin
parents: 74
diff changeset
71 /// </summary>
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
72 /// <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
73 /// <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
74 /// <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
75 /// <returns>The current promise.</returns>
138
f75cfa58e3d4 added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
cin
parents: 119
diff changeset
76 IPromise On(Action success, Action<Exception> error, Action<Exception> cancel);
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
77 IPromise On(Action success, Action<Exception> error);
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
78 IPromise On(Action success);
75
4439140706d0 major refactoring, added tasks support
cin
parents: 74
diff changeset
79
74
c4140283575c minor fixes
cin
parents: 66
diff changeset
80 /// <summary>
119
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
81 /// Adds specified listeners to the current promise.
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
82 /// </summary>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
83 /// <param name="handler">The handler called on the specified events.</param>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
84 /// <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
85 /// handler shoud be called.</param>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
86 /// <returns>The current promise.</returns>
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
87 IPromise On(Action handler, PromiseEventType events);
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
88
2573b562e328 Promises rewritten, added improved version of AsyncQueue
cin
parents: 104
diff changeset
89 /// <summary>
74
c4140283575c minor fixes
cin
parents: 66
diff changeset
90 /// Преобразует результат обещания к заданному типу и возвращает новое обещание.
c4140283575c minor fixes
cin
parents: 66
diff changeset
91 /// </summary>
66
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
92 IPromise<T> Cast<T>();
26
f0bf98e4d22c refactoring
cin
parents: 25
diff changeset
93
74
c4140283575c minor fixes
cin
parents: 66
diff changeset
94 /// <summary>
c4140283575c minor fixes
cin
parents: 66
diff changeset
95 /// Синхронизирует текущий поток с обещанием.
c4140283575c minor fixes
cin
parents: 66
diff changeset
96 /// </summary>
66
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
97 void Join();
74
c4140283575c minor fixes
cin
parents: 66
diff changeset
98 /// <summary>
c4140283575c minor fixes
cin
parents: 66
diff changeset
99 /// Синхронизирует текущий поток с обещанием.
c4140283575c minor fixes
cin
parents: 66
diff changeset
100 /// </summary>
c4140283575c minor fixes
cin
parents: 66
diff changeset
101 /// <param name="timeout">Время ожидания, по его истечению возникнет исключение.</param>
c4140283575c minor fixes
cin
parents: 66
diff changeset
102 /// <exception cref="TimeoutException">Превышено время ожидания.</exception>
66
790e8a997d30 Refactoring
cin
parents: 33
diff changeset
103 void Join(int timeout);
7
7ea9363fef6c inital progress handling
cin
parents:
diff changeset
104
7ea9363fef6c inital progress handling
cin
parents:
diff changeset
105 }
7ea9363fef6c inital progress handling
cin
parents:
diff changeset
106 }