# HG changeset patch # User cin # Date 1476405197 -10800 # Node ID 43b1017ce100bb1d76ae6fa113ea1a931d2b9bc0 # Parent ea485487a424c71d889a18b92a5595457a36931a# Parent b305c678923a8ab36f38923be7619053783bc09c Слияние с default diff -r ea485487a424 -r 43b1017ce100 .hgtags --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgtags Fri Oct 14 03:33:17 2016 +0300 @@ -0,0 +1,1 @@ +f1da3afc3521e0e1631ac19e09690bc0a241841a release v2.1 diff -r ea485487a424 -r 43b1017ce100 Implab/AbstractPromise.cs --- a/Implab/AbstractPromise.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/AbstractPromise.cs Fri Oct 14 03:33:17 2016 +0300 @@ -27,10 +27,8 @@ if ((m_mask & PromiseEventType.Success) != 0 && m_handler != null) { try { m_handler(); - } catch (Exception err) { - // avoid calling handler twice in case of error - if (m_error != null) - SignalError(err); + // Analysis disable once EmptyGeneralCatchClause + } catch { } } } @@ -55,8 +53,8 @@ if (m_cancel != null) { try { m_cancel(reason); - } catch (Exception err) { - SignalError(err); + // Analysis disable once EmptyGeneralCatchClause + } catch { } } else if ( (m_mask & PromiseEventType.Cancelled) != 0 && m_handler != null) { try { diff -r ea485487a424 -r 43b1017ce100 Implab/AbstractPromiseT.cs --- a/Implab/AbstractPromiseT.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/AbstractPromiseT.cs Fri Oct 14 03:33:17 2016 +0300 @@ -39,16 +39,14 @@ if (m_success != null) { try { m_success(result); - } catch(Exception err) { - SignalError(err); + // Analysis disable once EmptyGeneralCatchClause + } catch { } } else if ((m_mask & PromiseEventType.Success) != 0 && m_handler != null) { try { m_handler(); - } catch(Exception err) { - // avoid calling handler twice in case of error - if (m_error != null) - SignalError(err); + // Analysis disable once EmptyGeneralCatchClause + } catch { } } } @@ -73,8 +71,8 @@ if (m_cancel != null) { try { m_cancel(reason); - } catch (Exception err) { - SignalError(err); + // Analysis disable once EmptyGeneralCatchClause + } catch { } } else if ((m_mask & PromiseEventType.Cancelled) != 0 && m_handler != null) { try { diff -r ea485487a424 -r 43b1017ce100 Implab/ActionChainTask.cs --- a/Implab/ActionChainTask.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/ActionChainTask.cs Fri Oct 14 03:33:17 2016 +0300 @@ -23,10 +23,8 @@ var p = m_task(); p.On(SetResult, HandleErrorInternal, HandleCancelInternal); CancellationRequested(p.Cancel); - } catch (OperationCanceledException reason){ - HandleCancelInternal(reason); } catch(Exception err) { - HandleErrorInternal(err); + SetErrorInternal(err); } } } diff -r ea485487a424 -r 43b1017ce100 Implab/ActionChainTaskBase.cs --- a/Implab/ActionChainTaskBase.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/ActionChainTaskBase.cs Fri Oct 14 03:33:17 2016 +0300 @@ -36,10 +36,10 @@ // отдавать ли результат или подтвердить отмену (или вернуть ошибку). CancellationRequested(p.Cancel); } catch (Exception err) { - HandleErrorInternal(err); + SetErrorInternal(err); } } else { - HandleErrorInternal(reason ?? new OperationCanceledException()); + SetCancelledInternal(reason); } } @@ -50,7 +50,7 @@ p.On(SetResult, SetErrorInternal, SetCancelledInternal); CancellationRequested(p.Cancel); } catch (Exception err) { - SetErrorInternal(error); + SetErrorInternal(err); } } else { SetErrorInternal(error); diff -r ea485487a424 -r 43b1017ce100 Implab/ActionChainTaskT.cs --- a/Implab/ActionChainTaskT.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/ActionChainTaskT.cs Fri Oct 14 03:33:17 2016 +0300 @@ -14,10 +14,8 @@ var p = m_task(value); p.On(SetResult, HandleErrorInternal, HandleCancelInternal); CancellationRequested(p.Cancel); - } catch (OperationCanceledException reason) { - HandleCancelInternal(reason); } catch(Exception err) { - HandleErrorInternal(err); + SetErrorInternal(err); } } } diff -r ea485487a424 -r 43b1017ce100 Implab/ActionTask.cs --- a/Implab/ActionTask.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/ActionTask.cs Fri Oct 14 03:33:17 2016 +0300 @@ -12,10 +12,8 @@ try { m_task(); SetResult(); - } catch(OperationCanceledException reason) { - HandleCancelInternal(reason); } catch(Exception err) { - HandleErrorInternal(err); + SetErrorInternal(err); } } } diff -r ea485487a424 -r 43b1017ce100 Implab/ActionTaskBase.cs --- a/Implab/ActionTaskBase.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/ActionTaskBase.cs Fri Oct 14 03:33:17 2016 +0300 @@ -42,10 +42,10 @@ m_cancel(error); SetResult(); } catch(Exception err) { - HandleErrorInternal(err); + SetErrorInternal(err); } } else { - HandleErrorInternal(error ?? new OperationCanceledException()); + SetCancelledInternal(error); } } } diff -r ea485487a424 -r 43b1017ce100 Implab/ActionTaskT.cs --- a/Implab/ActionTaskT.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/ActionTaskT.cs Fri Oct 14 03:33:17 2016 +0300 @@ -12,10 +12,8 @@ try { m_task(value); SetResult(); - } catch(OperationCanceledException reason) { - HandleCancelInternal(reason); } catch(Exception err) { - HandleErrorInternal(err); + SetErrorInternal(err); } } } diff -r ea485487a424 -r 43b1017ce100 Implab/Components/RunnableComponent.cs --- a/Implab/Components/RunnableComponent.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/Components/RunnableComponent.cs Fri Oct 14 03:33:17 2016 +0300 @@ -120,6 +120,20 @@ prev = m_pending; + Action errorOrCancel = e => { + if (e == null) + e = new OperationCanceledException(); + + lock (m_stateMachine) { + if (m_pending == promise) { + Move(Commands.Fail); + m_pending = null; + m_lastError = e; + } + } + throw new PromiseTransientException(e); + }; + promise = task.Then( () => { lock(m_stateMachine) { @@ -128,16 +142,9 @@ m_pending = null; } } - }, e => { - lock(m_stateMachine) { - if (m_pending == promise) { - Move(Commands.Fail); - m_pending = null; - m_lastError = e; - } - } - throw new PromiseTransientException(e); - } + }, + errorOrCancel, + errorOrCancel ); m_pending = promise; diff -r ea485487a424 -r 43b1017ce100 Implab/FuncChainTask.cs --- a/Implab/FuncChainTask.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/FuncChainTask.cs Fri Oct 14 03:33:17 2016 +0300 @@ -15,10 +15,8 @@ var operation = m_task(); operation.On(SetResult, HandleErrorInternal, HandleCancelInternal); CancellationRequested(operation.Cancel); - } catch (OperationCanceledException reason) { - HandleCancelInternal(reason); } catch (Exception err) { - HandleErrorInternal(err); + SetErrorInternal(err); } } } diff -r ea485487a424 -r 43b1017ce100 Implab/FuncChainTaskBase.cs --- a/Implab/FuncChainTaskBase.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/FuncChainTaskBase.cs Fri Oct 14 03:33:17 2016 +0300 @@ -43,10 +43,10 @@ p.On(SetResult, HandleErrorInternal, SetCancelledInternal); CancellationRequested(p.Cancel); } catch (Exception err) { - HandleErrorInternal(err); + SetErrorInternal(err); } } else { - HandleErrorInternal(reason ?? new OperationCanceledException()); + SetCancelledInternal(reason); } } } diff -r ea485487a424 -r 43b1017ce100 Implab/FuncChainTaskT.cs --- a/Implab/FuncChainTaskT.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/FuncChainTaskT.cs Fri Oct 14 03:33:17 2016 +0300 @@ -14,10 +14,8 @@ var operation = m_task(value); operation.On(SetResult, HandleErrorInternal, SetCancelled); CancellationRequested(operation.Cancel); - } catch (OperationCanceledException reason) { - HandleCancelInternal(reason); } catch (Exception err) { - HandleErrorInternal(err); + SetErrorInternal(err); } } } diff -r ea485487a424 -r 43b1017ce100 Implab/FuncTask.cs --- a/Implab/FuncTask.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/FuncTask.cs Fri Oct 14 03:33:17 2016 +0300 @@ -13,10 +13,8 @@ if (m_task != null && LockCancelation()) { try { SetResult(m_task()); - } catch(OperationCanceledException reason) { - HandleCancelInternal(reason); } catch(Exception err) { - HandleErrorInternal(err); + SetErrorInternal(err); } } } diff -r ea485487a424 -r 43b1017ce100 Implab/FuncTaskBase.cs --- a/Implab/FuncTaskBase.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/FuncTaskBase.cs Fri Oct 14 03:33:17 2016 +0300 @@ -40,10 +40,10 @@ try { SetResult(m_cancel(reason)); } catch (Exception err) { - HandleErrorInternal(err); + SetErrorInternal(err); } } else { - HandleErrorInternal(reason ?? new OperationCanceledException()); + SetCancelledInternal(reason); } } diff -r ea485487a424 -r 43b1017ce100 Implab/FuncTaskT.cs --- a/Implab/FuncTaskT.cs Wed May 04 12:28:08 2016 +0300 +++ b/Implab/FuncTaskT.cs Fri Oct 14 03:33:17 2016 +0300 @@ -12,10 +12,8 @@ if (m_task != null && LockCancelation()) { try { SetResult(m_task(value)); - } catch(OperationCanceledException reason) { - HandleCancelInternal(reason); } catch(Exception err) { - HandleErrorInternal(err); + SetErrorInternal(err); } } }