[asterisk-scf-commits] asterisk-scf/integration/ice-util-cpp.git branch "retry_deux" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Fri Mar 30 13:15:47 CDT 2012
branch "retry_deux" has been updated
via 495d0049efbbfd4ae25dcc87c385d569a8b83c05 (commit)
from 6227c52f466b42b7de46d7bbaaf8b3d651f16458 (commit)
Summary of changes:
include/AsteriskSCF/Operations/OperationMonitor.h | 33 +++++++++++++++++++-
1 files changed, 31 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit 495d0049efbbfd4ae25dcc87c385d569a8b83c05
Author: Brent Eagles <beagles at digium.com>
Date: Fri Mar 30 15:45:06 2012 -0230
Slight tweaking of context result templates to make it a bit more straightforward for
non-AMD callers.
diff --git a/include/AsteriskSCF/Operations/OperationMonitor.h b/include/AsteriskSCF/Operations/OperationMonitor.h
index 6be007c..c9f734d 100755
--- a/include/AsteriskSCF/Operations/OperationMonitor.h
+++ b/include/AsteriskSCF/Operations/OperationMonitor.h
@@ -121,6 +121,15 @@ public:
mMonitor->setCompleted();
onSetCompleted();
}
+
+ /**
+ * Shorthand for getMonitor()->waitForResults(). TODO: see how much
+ * effort it would take to hide the monitor altogether.
+ */
+ bool waitForResults()
+ {
+ return mMonitor->waitForResults();
+ }
protected:
IceUtil::Mutex mLock;
@@ -153,8 +162,28 @@ class ContextResultData : virtual public ContextData
public:
void setResult(const RT& val);
+ /**
+ * Can't get much simpler for synchronous calls than this:
+ * - blocks until results are computed
+ * - throws an exception if such a thing occurred.
+ * - otherwise returns result.
+ */
RT getResult()
{
+ if (!mMonitor->waitForResults())
+ {
+ //
+ // TODO: Unsure what the best course of action is here.. this
+ // implies that the operation was cancelled and results should
+ // not be expected.
+ //
+ throw std::exception("Cancelled operation");
+ }
+
+ if (mExceptionResult)
+ {
+ mExceptionResult->exception()->ice_throw();
+ }
return mResult;
}
@@ -417,7 +446,7 @@ public:
}
else
{
- cbPtr->ice_response(ContextResultData<RT>::getResult());
+ cbPtr->ice_response(ContextResultData<RT>::mResult);
}
return;
}
@@ -430,7 +459,7 @@ private:
for (typename std::vector<CB>::const_iterator iter = mCallbacks.begin();
iter != mCallbacks.end(); ++iter)
{
- (*iter)->ice_response(ContextResultData<RT>::getResult());
+ (*iter)->ice_response(ContextResultData<RT>::mResult);
}
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/ice-util-cpp.git
More information about the asterisk-scf-commits
mailing list