summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2009-12-02 20:58:58 +0100
committerBenoit Foucher <benoit@zeroc.com>2009-12-02 20:58:58 +0100
commit7da7bd6dfa7cf1d89afaab1e3e293891d881136b (patch)
tree4fa39d4784e31f440c147182c798ccda7534ae3a /cpp/src
parentMake loading of IceSSL when using unique names easier (diff)
downloadice-7da7bd6dfa7cf1d89afaab1e3e293891d881136b.tar.bz2
ice-7da7bd6dfa7cf1d89afaab1e3e293891d881136b.tar.xz
ice-7da7bd6dfa7cf1d89afaab1e3e293891d881136b.zip
More AMI mapping improvements
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Glacier2/SessionRouterI.cpp48
-rw-r--r--cpp/src/Glacier2/SessionRouterI.h6
-rw-r--r--cpp/src/Ice/Proxy.cpp25
-rw-r--r--cpp/src/slice2cpp/Gen.cpp123
-rw-r--r--cpp/src/slice2cs/Gen.cpp14
-rw-r--r--cpp/src/slice2java/Gen.cpp4
6 files changed, 114 insertions, 106 deletions
diff --git a/cpp/src/Glacier2/SessionRouterI.cpp b/cpp/src/Glacier2/SessionRouterI.cpp
index a6e6e8d1556..5d699e44083 100644
--- a/cpp/src/Glacier2/SessionRouterI.cpp
+++ b/cpp/src/Glacier2/SessionRouterI.cpp
@@ -483,39 +483,6 @@ private:
}
-namespace
-{
-
-class SessionPingCallback : public IceUtil::Shared
-{
-public:
-
- SessionPingCallback(const Glacier2::InstancePtr& instance, const Ice::ConnectionPtr& connection) :
- _instance(instance),
- _connection(connection)
- {
- }
-
- void exception(const Ice::Exception&)
- {
- try
- {
- _instance->sessionRouter()->destroySession(_connection);
- }
- catch(...)
- {
- }
- }
-
-private:
-
- Glacier2::InstancePtr _instance;
- Ice::ConnectionPtr _connection;
-};
-typedef IceUtil::Handle<SessionPingCallback> SessionPingCallbackPtr;
-
-}
-
using namespace Glacier2;
Glacier2::CreateSession::CreateSession(const SessionRouterIPtr& sessionRouter, const string& user,
@@ -748,8 +715,10 @@ Glacier2::SessionRouterI::SessionRouterI(const InstancePtr& instance,
_sessionThread(_sessionTimeout > IceUtil::Time() ? new SessionThread(this, _sessionTimeout) : 0),
_routersByConnectionHint(_routersByConnection.end()),
_routersByCategoryHint(_routersByCategory.end()),
+ _sessionPingCallback(newCallback_Object_ice_ping(this, &SessionRouterI::sessionPingException)),
_destroy(false)
{
+
//
// This session router is used directly as servant for the main
// Glacier2 router Ice object.
@@ -835,6 +804,8 @@ Glacier2::SessionRouterI::destroy()
sessionThread = _sessionThread;
_sessionThread = 0;
+
+ _sessionPingCallback = 0; // Break cyclic reference count.
}
//
@@ -979,9 +950,8 @@ Glacier2::SessionRouterI::refreshSession(const Ice::Current& current)
//
// Ping the session to ensure it does not timeout.
//
- SessionPingCallbackPtr cb = new SessionPingCallback(_instance, current.con);
- Ice::CallbackPtr d = Ice::newCallback(cb, &SessionPingCallback::exception);
- router->getSession()->begin_ice_ping(d);
+ assert(_sessionPingCallback);
+ router->getSession()->begin_ice_ping(_sessionPingCallback, current.con);
}
void
@@ -1173,6 +1143,12 @@ Glacier2::SessionRouterI::expireSessions()
}
}
+void
+Glacier2::SessionRouterI::sessionPingException(const Ice::Exception&, const Ice::ConnectionPtr& con)
+{
+ destroySession(con);
+}
+
bool
Glacier2::SessionRouterI::startCreateSession(const CreateSessionPtr& cb, const ConnectionPtr& connection)
{
diff --git a/cpp/src/Glacier2/SessionRouterI.h b/cpp/src/Glacier2/SessionRouterI.h
index 7f9aa5626de..fc8f43168db 100644
--- a/cpp/src/Glacier2/SessionRouterI.h
+++ b/cpp/src/Glacier2/SessionRouterI.h
@@ -110,6 +110,8 @@ public:
private:
+ void sessionPingException(const Ice::Exception&, const ::Ice::ConnectionPtr&);
+
bool startCreateSession(const CreateSessionPtr&, const Ice::ConnectionPtr&);
void finishCreateSession(const Ice::ConnectionPtr&, const RouterIPtr&);
friend class Glacier2::CreateSession;
@@ -150,7 +152,9 @@ private:
mutable std::map<std::string, RouterIPtr>::iterator _routersByCategoryHint;
std::map<Ice::ConnectionPtr, CreateSessionPtr> _pending;
-
+
+ Ice::Callback_Object_ice_pingPtr _sessionPingCallback;
+
bool _destroy;
};
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index cb31063381e..7ff28fdf705 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -418,7 +418,7 @@ IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb,
&AMI_Object_ice_invoke::__exception);
}
::Ice::AsyncResultPtr result = begin_ice_invoke(operation, mode, inParams, del);
- return result->sentSynchronously();
+ return result->isSentSynchronously();
}
bool
@@ -443,7 +443,7 @@ IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb,
&AMI_Object_ice_invoke::__exception);
}
::Ice::AsyncResultPtr result = begin_ice_invoke(operation, mode, inParams, context, del);
- return result->sentSynchronously();
+ return result->isSentSynchronously();
}
AsyncResultPtr
@@ -539,7 +539,7 @@ IceProxy::Ice::Object::ice_invoke_async(const AMI_Array_Object_ice_invokePtr& cb
&AMI_Array_Object_ice_invoke::__exception);
}
::Ice::AsyncResultPtr result = begin_ice_invoke(operation, mode, inParams, del);
- return result->sentSynchronously();
+ return result->isSentSynchronously();
}
bool
@@ -564,7 +564,7 @@ IceProxy::Ice::Object::ice_invoke_async(const AMI_Array_Object_ice_invokePtr& cb
&AMI_Array_Object_ice_invoke::__exception);
}
::Ice::AsyncResultPtr result = begin_ice_invoke(operation, mode, inParams, context, del);
- return result->sentSynchronously();
+ return result->isSentSynchronously();
}
AsyncResultPtr
@@ -592,7 +592,7 @@ IceProxy::Ice::Object::begin_ice_invoke(const string& operation,
}
bool
-IceProxy::Ice::Object::end_ice_invoke(pair<const Byte*, const Byte*>& outParams, const AsyncResultPtr& __result)
+IceProxy::Ice::Object::___end_ice_invoke(pair<const Byte*, const Byte*>& outParams, const AsyncResultPtr& __result)
{
AsyncResult::__check(__result, this, ice_invoke_name);
bool ok = __result->__wait();
@@ -1118,8 +1118,19 @@ IceProxy::Ice::Object::ice_flushBatchRequests()
bool
IceProxy::Ice::Object::ice_flushBatchRequests_async(const AMI_Object_ice_flushBatchRequestsPtr& cb)
{
- ::Ice::AsyncResultPtr result = begin_ice_flushBatchRequests(newAMICallback(cb));
- return result->sentSynchronously();
+ Callback_Object_ice_flushBatchRequestsPtr __del;
+ if(dynamic_cast< AMISentCallback*>(cb.get()))
+ {
+ __del = newCallback_Object_ice_flushBatchRequests(cb,
+ &AMI_Object_ice_flushBatchRequests::__exception,
+ &AMI_Object_ice_flushBatchRequests::__sent);
+ }
+ else
+ {
+ __del = newCallback_Object_ice_flushBatchRequests(cb, &AMI_Object_ice_flushBatchRequests::__exception);
+ }
+ ::Ice::AsyncResultPtr result = begin_ice_flushBatchRequests(0, __del, 0);
+ return result->isSentSynchronously();
}
::Ice::AsyncResultPtr
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index fa2e480a625..8fef2765047 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -2849,8 +2849,6 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
else
{
C << nl << "::IceInternal::CallbackBasePtr __del;";
- C << nl << "if(ice_isTwoway())";
- C << sb;
C << nl << "if(dynamic_cast< ::Ice::AMISentCallback*>(__cb.get()))";
C << sb;
C << nl << " __del = " << classScope << "new" << delName << "(__cb, &" << opScopedAMI << "::__response, &"
@@ -2861,14 +2859,9 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
C << nl << " __del = " << classScope << "new" << delName << "(__cb, &" << opScopedAMI << "::__response, &"
<< opScopedAMI << "::__exception);";
C << eb;
- C << eb;
- C << nl << "else";
- C << sb;
- C << nl << "__del = ::Ice::newAMICallback(__cb);";
- C << eb;
}
C << nl << "::Ice::AsyncResultPtr __ar = begin_" << name << spar << argsAMI << "0, __del" << epar << ';';
- C << nl << "return __ar->sentSynchronously();";
+ C << nl << "return __ar->isSentSynchronously();";
C << eb;
C << sp << nl << "bool" << nl << "IceProxy" << scope << name << "_async" << spar
@@ -2892,7 +2885,6 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
else
{
C << nl << "::IceInternal::CallbackBasePtr __del;";
- C << nl << "if(ice_isTwoway())";
C << nl << "if(dynamic_cast< ::Ice::AMISentCallback*>(__cb.get()))";
C << sb;
C << nl << " __del = " << classScope << "new" << delName << "(__cb, &" << opScopedAMI << "::__response, &"
@@ -2903,14 +2895,10 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
C << nl << " __del = " << classScope << "new" << delName << "(__cb, &" << opScopedAMI << "::__response, &"
<< opScopedAMI << "::__exception);";
C << eb;
- C << nl << "else";
- C << sb;
- C << nl << "__del = ::Ice::newAMICallback(__cb);";
- C << eb;
}
C << nl << "::Ice::AsyncResultPtr __ar = begin_" << name << spar << argsAMI << "&__ctx" << "__del" << epar
<< ';';
- C << nl << "return __ar->sentSynchronously();";
+ C << nl << "return __ar->isSentSynchronously();";
C << eb;
}
}
@@ -5359,17 +5347,13 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr&
H.inc();
H << sp << nl << "typedef IceUtil::Handle<T> TPtr;";
- if(withCookie)
- {
- H << nl << "typedef IceUtil::Handle<CT> CTPtr;";
- }
string cookieT;
string comCookieT;
if(withCookie)
{
- cookieT = "const CTPtr&";
- comCookieT = " , const CTPtr&";
+ cookieT = "const CT&";
+ comCookieT = " , const CT&";
}
H << sp << nl << "typedef void (T::*Exception)(const ::Ice::Exception&" << comCookieT << ");";
@@ -5473,7 +5457,7 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr&
H << outArgs;
if(withCookie)
{
- H << "CTPtr::dynamicCast(__result->getCookie())";
+ H << "CT::dynamicCast(__result->getCookie())";
}
H << epar << ';';
H.zeroIndent();
@@ -5487,7 +5471,7 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr&
H << outArgs;
if(withCookie)
{
- H << "CTPtr::dynamicCast(__result->getCookie())";
+ H << "CT::dynamicCast(__result->getCookie())";
}
H << epar << ';';
H.zeroIndent();
@@ -5501,48 +5485,75 @@ Slice::Gen::AsyncCallbackTemplateVisitor::generateOperation(const OperationPtr&
H << eb << ';';
// Factory method
- if(withCookie)
+ for(int i = 0; i < 2; i++)
{
- cookieT = "const ::IceUtil::Handle<CT>&";
- comCookieT = " , const ::IceUtil::Handle<CT>&";
- H << sp << nl << "template<class T, typename CT> " << delName << "Ptr";
- }
- else
- {
- H << sp << nl << "template<class T> " << delName << "Ptr";
- }
+ string callbackT = i == 0 ? "const IceUtil::Handle<T>&" : "T*";
- H << nl << "new" << delName << "(const ::IceUtil::Handle<T>& instance, ";
- if(p->returnsData())
- {
- H << "void (T::*cb)" << spar;
- if(ret)
+ if(withCookie)
{
- H << retS;
+ cookieT = "const CT&";
+ comCookieT = " , const CT&";
+ H << sp << nl << "template<class T, typename CT> " << delName << "Ptr";
}
- H << outDecls;
+ else
+ {
+ H << sp << nl << "template<class T> " << delName << "Ptr";
+ }
+
+ H << nl << "new" << delName << "(" << callbackT << " instance, ";
+ if(p->returnsData())
+ {
+ H << "void (T::*cb)" << spar;
+ if(ret)
+ {
+ H << retS;
+ }
+ H << outDecls;
+ if(withCookie)
+ {
+ H << cookieT;
+ }
+ H << epar << ", ";
+ }
+ else
+ {
+ H << "void (T::*cb)(" << cookieT << "),";
+ }
+ H << "void (T::*excb)(" << "const ::Ice::Exception&" << comCookieT << "),";
+ H << "void (T::*sentcb)(bool" << comCookieT << ") = 0)";
+ H << sb;
if(withCookie)
{
- H << cookieT;
+ H << nl << "return new " << delTmplName << "<T, CT>(instance, cb, excb, sentcb);";
}
- H << epar << ", ";
- }
- else
- {
- H << "void (T::*cb)(" << cookieT << "),";
- }
- H << "void (T::*excb)(" << "const ::Ice::Exception&" << comCookieT << ") = 0,";
- H << "void (T::*sentcb)(bool" << comCookieT << ") = 0)";
- H << sb;
- if(withCookie)
- {
- H << nl << "return new " << delTmplName << "<T, CT>(instance, cb, excb, sentcb);";
- }
- else
- {
- H << nl << "return new " << delTmplName << "<T>(instance, cb, excb, sentcb);";
+ else
+ {
+ H << nl << "return new " << delTmplName << "<T>(instance, cb, excb, sentcb);";
+ }
+ H << eb;
+
+ if(withCookie)
+ {
+ H << sp << nl << "template<class T, typename CT> " << delName << "Ptr";
+ }
+ else
+ {
+ H << sp << nl << "template<class T> " << delName << "Ptr";
+ }
+ H << nl << "new" << delName << "(" << callbackT << " instance, ";
+ H << "void (T::*excb)(" << "const ::Ice::Exception&" << comCookieT << "),";
+ H << "void (T::*sentcb)(bool" << comCookieT << ") = 0)";
+ H << sb;
+ if(withCookie)
+ {
+ H << nl << "return new " << delTmplName << "<T, CT>(instance, 0, excb, sentcb);";
+ }
+ else
+ {
+ H << nl << "return new " << delTmplName << "<T>(instance, 0, excb, sentcb);";
+ }
+ H << eb;
}
- H << eb;
}
Slice::Gen::IceInternalVisitor::IceInternalVisitor(Output& h, Output& c, const string& dllExport) :
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 1718b292191..101579c4086 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -4321,6 +4321,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << eb;
_out << nl << "return;";
_out << eb;
+ _out << nl << "if(cb__ != null)";
+ _out << sb;
_out << nl << "cb__" << spar;
if(ret)
{
@@ -4332,13 +4334,17 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
}
_out << epar << ';';
_out << eb;
+ _out << eb;
}
else
{
_out << sp << nl << "private void " << op->name() << "_completed__(" << delType << " cb__)";
_out << sb;
+ _out << nl << "if(cb__ != null)";
+ _out << sb;
_out << nl << "cb__();";
_out << eb;
+ _out << eb;
}
}
@@ -4370,9 +4376,9 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << ".whenCompleted(cb__.response__, cb__.exception__);";
_out << nl << "if(cb__ is Ice.AMISentCallback)";
_out << sb;
- _out << nl << "result__.whenSent(cb__.sent__);";
+ _out << nl << "result__.whenSent((Ice.AsyncCallback)cb__.sent__);";
_out << eb;
- _out << "return result__.sentSynchronously();";
+ _out << "return result__.isSentSynchronously();";
_out << eb;
_out << sp;
@@ -4385,9 +4391,9 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << ".whenCompleted(cb__.response__, cb__.exception__);";
_out << nl << "if(cb__ is Ice.AMISentCallback)";
_out << sb;
- _out << nl << "result__.whenSent(cb__.sent__);";
+ _out << nl << "result__.whenSent((Ice.AsyncCallback)cb__.sent__);";
_out << eb;
- _out << "return result__.sentSynchronously();";
+ _out << "return result__.isSentSynchronously();";
_out << eb;
}
}
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 4300a1f2f23..736241f8b83 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -4025,7 +4025,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sb;
out << nl << "Ice.AsyncResult __r = begin_" << op->name() << spar << argsAMI << "null" << "false"
<< "__cb" << epar << ';';
- out << nl << "return __r.sentSynchronously();";
+ out << nl << "return __r.isSentSynchronously();";
out << eb;
out << sp;
@@ -4034,7 +4034,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sb;
out << nl << "Ice.AsyncResult __r = begin_" << op->name() << spar << argsAMI << "__ctx" << "true"
<< "__cb" << epar << ';';
- out << nl << "return __r.sentSynchronously();";
+ out << nl << "return __r.isSentSynchronously();";
out << eb;
}
}