Mercurial > pub > ImplabNet
comparison Implab/AbstractPromiseT.cs @ 156:97fbbf816844 v2
Promises: SignalXXX methods merged into SignalHandler method.
Components: RunnableComponent In progress
author | cin |
---|---|
date | Mon, 15 Feb 2016 04:22:15 +0300 |
parents | 706fccb85524 |
children | 86187b01c4e0 |
comparison
equal
deleted
inserted
replaced
155:037df317f126 | 156:97fbbf816844 |
---|---|
173 var signal = new Signal(); | 173 var signal = new Signal(); |
174 AddHandler(new HandlerDescriptor(signal.Set, PromiseEventType.All)); | 174 AddHandler(new HandlerDescriptor(signal.Set, PromiseEventType.All)); |
175 return signal; | 175 return signal; |
176 } | 176 } |
177 | 177 |
178 protected override void SignalSuccess(HandlerDescriptor handler) { | 178 protected override void SignalHandler(HandlerDescriptor handler, int signal) { |
179 handler.SignalSuccess(m_result); | 179 switch (signal) { |
180 } | 180 case SUCCEEDED_STATE: |
181 | 181 handler.SignalSuccess(m_result); |
182 protected override void SignalError(HandlerDescriptor handler, Exception error) { | 182 break; |
183 handler.SignalError(error); | 183 case REJECTED_STATE: |
184 } | 184 handler.SignalError(Error); |
185 | 185 break; |
186 protected override void SignalCancelled(HandlerDescriptor handler, Exception reason) { | 186 case CANCELLED_STATE: |
187 handler.SignalCancel(reason); | 187 handler.SignalCancel(CancellationReason); |
188 break; | |
189 default: | |
190 throw new InvalidOperationException(String.Format("Invalid promise signal: {0}", signal)); | |
191 } | |
188 } | 192 } |
189 | 193 |
190 #endregion | 194 #endregion |
191 | 195 |
192 T m_result; | 196 T m_result; |