summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Ice/OutgoingAsync.h3
-rw-r--r--cpp/include/Ice/Proxy.h4
-rw-r--r--cpp/src/Ice/CollocatedRequestHandler.cpp8
-rw-r--r--cpp/src/Ice/CollocatedRequestHandler.h3
-rw-r--r--cpp/src/Ice/ConnectRequestHandler.cpp45
-rw-r--r--cpp/src/Ice/ConnectRequestHandler.h3
-rw-r--r--cpp/src/Ice/ConnectionRequestHandler.cpp8
-rw-r--r--cpp/src/Ice/ConnectionRequestHandler.h3
-rw-r--r--cpp/src/Ice/Outgoing.cpp6
-rw-r--r--cpp/src/Ice/OutgoingAsync.cpp77
-rw-r--r--cpp/src/Ice/Proxy.cpp28
-rw-r--r--cpp/src/Ice/RequestHandler.h3
-rw-r--r--cpp/src/slice2cs/Gen.cpp191
-rw-r--r--cpp/src/slice2java/Gen.cpp279
-rw-r--r--cpp/test/Ice/metrics/AllTests.cpp70
-rw-r--r--cpp/test/Ice/operations/AllTests.cpp6
-rw-r--r--cpp/test/Ice/operations/BatchOneways.cpp1
-rw-r--r--cpp/test/Ice/operations/BatchOnewaysAMI.cpp206
-rw-r--r--cpp/test/Ice/operations/Makefile6
-rw-r--r--cpp/test/Ice/operations/Makefile.mak4
20 files changed, 542 insertions, 412 deletions
diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h
index e80b97a1616..13185c386b4 100644
--- a/cpp/include/Ice/OutgoingAsync.h
+++ b/cpp/include/Ice/OutgoingAsync.h
@@ -112,7 +112,7 @@ public:
bool __wait();
void __throwUserException();
- void __invokeExceptionAsync(const Exception&);
+ virtual void __invokeExceptionAsync(const Exception&);
static void __check(const AsyncResultPtr&, const ::IceProxy::Ice::Object*, const ::std::string&);
static void __check(const AsyncResultPtr&, const Connection*, const ::std::string&);
@@ -255,6 +255,7 @@ public:
virtual bool __sent();
virtual void __invokeSent();
virtual void __finished(const Ice::Exception&);
+ virtual void __invokeExceptionAsync(const Ice::Exception&);
void __finished();
bool __invoke(bool);
diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h
index 610d095fbb9..8ef8469537b 100644
--- a/cpp/include/Ice/Proxy.h
+++ b/cpp/include/Ice/Proxy.h
@@ -884,7 +884,7 @@ public:
void __invoke(::IceInternal::Outgoing&) const;
void __end(const ::Ice::AsyncResultPtr&, const std::string&) const;
- ::IceInternal::RequestHandlerPtr __getRequestHandler(bool);
+ ::IceInternal::RequestHandlerPtr __getRequestHandler();
void __setRequestHandler(const ::IceInternal::RequestHandlerPtr&, const ::IceInternal::RequestHandlerPtr&);
protected:
@@ -893,7 +893,7 @@ protected:
private:
- ::IceInternal::RequestHandlerPtr createRequestHandler(bool);
+ ::IceInternal::RequestHandlerPtr createRequestHandler();
bool ice_isA(const ::std::string&, const ::Ice::Context*);
::Ice::AsyncResultPtr begin_ice_isA(const ::std::string&,
diff --git a/cpp/src/Ice/CollocatedRequestHandler.cpp b/cpp/src/Ice/CollocatedRequestHandler.cpp
index fde2cbcb0b1..452511591a5 100644
--- a/cpp/src/Ice/CollocatedRequestHandler.cpp
+++ b/cpp/src/Ice/CollocatedRequestHandler.cpp
@@ -561,7 +561,13 @@ CollocatedRequestHandler::invokeException(Int requestId, const LocalException& e
}
ConnectionIPtr
-CollocatedRequestHandler::getConnection(bool /*wait*/)
+CollocatedRequestHandler::getConnection()
+{
+ return 0;
+}
+
+ConnectionIPtr
+CollocatedRequestHandler::waitForConnection()
{
return 0;
}
diff --git a/cpp/src/Ice/CollocatedRequestHandler.h b/cpp/src/Ice/CollocatedRequestHandler.h
index 3e106a1f280..7b80a2a036a 100644
--- a/cpp/src/Ice/CollocatedRequestHandler.h
+++ b/cpp/src/Ice/CollocatedRequestHandler.h
@@ -61,7 +61,8 @@ public:
const ReferencePtr& getReference() const { return _reference; } // Inlined for performances.
- virtual Ice::ConnectionIPtr getConnection(bool);
+ virtual Ice::ConnectionIPtr getConnection();
+ virtual Ice::ConnectionIPtr waitForConnection();
void invokeRequest(Outgoing*);
AsyncStatus invokeAsyncRequest(OutgoingAsync*);
diff --git a/cpp/src/Ice/ConnectRequestHandler.cpp b/cpp/src/Ice/ConnectRequestHandler.cpp
index a8e83697996..10f756be30c 100644
--- a/cpp/src/Ice/ConnectRequestHandler.cpp
+++ b/cpp/src/Ice/ConnectRequestHandler.cpp
@@ -287,25 +287,37 @@ ConnectRequestHandler::asyncRequestTimedOut(const OutgoingAsyncMessageCallbackPt
}
Ice::ConnectionIPtr
-ConnectRequestHandler::getConnection(bool waitInit)
+ConnectRequestHandler::getConnection()
{
Lock sync(*this);
- if(waitInit)
+ if(_exception.get())
{
- if(_exception.get())
- {
- throw RetryException(*_exception.get());
- }
-
- //
- // Wait for the connection establishment to complete or fail.
- //
- while(!_initialized && !_exception.get())
- {
- wait();
- }
+ _exception->ice_throw();
+ return 0; // Keep the compiler happy.
+ }
+ else
+ {
+ return _connection;
+ }
+}
+
+Ice::ConnectionIPtr
+ConnectRequestHandler::waitForConnection()
+{
+ Lock sync(*this);
+ if(_exception.get())
+ {
+ throw RetryException(*_exception.get());
}
-
+
+ //
+ // Wait for the connection establishment to complete or fail.
+ //
+ while(!_initialized && !_exception.get())
+ {
+ wait();
+ }
+
if(_exception.get())
{
_exception->ice_throw();
@@ -313,9 +325,8 @@ ConnectRequestHandler::getConnection(bool waitInit)
}
else
{
- assert(!waitInit || _initialized);
return _connection;
- }
+ }
}
void
diff --git a/cpp/src/Ice/ConnectRequestHandler.h b/cpp/src/Ice/ConnectRequestHandler.h
index 4776d985ff3..a95f62f8717 100644
--- a/cpp/src/Ice/ConnectRequestHandler.h
+++ b/cpp/src/Ice/ConnectRequestHandler.h
@@ -47,7 +47,8 @@ public:
virtual void requestTimedOut(OutgoingMessageCallback*);
virtual void asyncRequestTimedOut(const OutgoingAsyncMessageCallbackPtr&);
- virtual Ice::ConnectionIPtr getConnection(bool);
+ virtual Ice::ConnectionIPtr getConnection();
+ virtual Ice::ConnectionIPtr waitForConnection();
virtual void setConnection(const Ice::ConnectionIPtr&, bool);
virtual void setException(const Ice::LocalException&);
diff --git a/cpp/src/Ice/ConnectionRequestHandler.cpp b/cpp/src/Ice/ConnectionRequestHandler.cpp
index 0d503201310..fba1ee9dc34 100644
--- a/cpp/src/Ice/ConnectionRequestHandler.cpp
+++ b/cpp/src/Ice/ConnectionRequestHandler.cpp
@@ -81,7 +81,13 @@ ConnectionRequestHandler::asyncRequestTimedOut(const OutgoingAsyncMessageCallbac
}
Ice::ConnectionIPtr
-ConnectionRequestHandler::getConnection(bool /*wait*/)
+ConnectionRequestHandler::getConnection()
+{
+ return _connection;
+}
+
+Ice::ConnectionIPtr
+ConnectionRequestHandler::waitForConnection()
{
return _connection;
}
diff --git a/cpp/src/Ice/ConnectionRequestHandler.h b/cpp/src/Ice/ConnectionRequestHandler.h
index 234dbf5f5a6..d8d4b1f2ae5 100644
--- a/cpp/src/Ice/ConnectionRequestHandler.h
+++ b/cpp/src/Ice/ConnectionRequestHandler.h
@@ -34,7 +34,8 @@ public:
virtual void requestTimedOut(OutgoingMessageCallback*);
virtual void asyncRequestTimedOut(const OutgoingAsyncMessageCallbackPtr&);
- virtual Ice::ConnectionIPtr getConnection(bool);
+ virtual Ice::ConnectionIPtr getConnection();
+ virtual Ice::ConnectionIPtr waitForConnection();
private:
diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp
index fce704f0fe9..66509a2bedc 100644
--- a/cpp/src/Ice/Outgoing.cpp
+++ b/cpp/src/Ice/Outgoing.cpp
@@ -54,7 +54,7 @@ IceInternal::Outgoing::Outgoing(IceProxy::Ice::Object* proxy, const string& oper
{
try
{
- _handler = proxy->__getRequestHandler(true);
+ _handler = proxy->__getRequestHandler();
_handler->prepareBatchRequest(&_os);
break;
}
@@ -150,7 +150,7 @@ IceInternal::Outgoing::invoke()
_exception.reset(0);
_sent = false;
- _handler = _proxy->__getRequestHandler(false);
+ _handler = _proxy->__getRequestHandler();
if(_handler->sendRequest(this)) // Request sent and no response expected, we're done.
{
@@ -542,7 +542,7 @@ IceInternal::BatchOutgoing::invoke()
RequestHandlerPtr handler;
try
{
- handler = _proxy->__getRequestHandler(false);
+ handler = _proxy->__getRequestHandler();
if(handler->sendRequest(this))
{
return;
diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp
index 749384821f4..c9d0ac28234 100644
--- a/cpp/src/Ice/OutgoingAsync.cpp
+++ b/cpp/src/Ice/OutgoingAsync.cpp
@@ -456,15 +456,42 @@ IceInternal::OutgoingAsync::__prepare(const std::string& operation, OperationMod
_observer.attach(_proxy.get(), operation, context);
- //
- // Can't call async via a batch proxy.
- //
- if(_proxy->ice_isBatchOneway() || _proxy->ice_isBatchDatagram())
+ switch(_proxy->__reference()->getMode())
{
- throw Ice::FeatureNotSupportedException(__FILE__, __LINE__, "can't send batch requests with AMI");
- }
+ case Reference::ModeTwoway:
+ case Reference::ModeOneway:
+ case Reference::ModeDatagram:
+ {
+ _os.writeBlob(requestHdr, sizeof(requestHdr));
+ break;
+ }
- _os.writeBlob(requestHdr, sizeof(requestHdr));
+ case Reference::ModeBatchOneway:
+ case Reference::ModeBatchDatagram:
+ {
+ while(true)
+ {
+ try
+ {
+ _handler = _proxy->__getRequestHandler();
+ _handler->prepareBatchRequest(&_os);
+ break;
+ }
+ catch(const RetryException&)
+ {
+ _proxy->__setRequestHandler(_handler, 0); // Clear request handler and retry.
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ _observer.failed(ex.ice_name());
+ _proxy->__setRequestHandler(_handler, 0); // Clear request handler
+ _handler = 0;
+ throw;
+ }
+ }
+ break;
+ }
+ }
Reference* ref = _proxy->__reference().get();
@@ -535,7 +562,7 @@ IceInternal::OutgoingAsync::__sent()
_sent = true;
assert(!(_state & Done));
- if(_proxy->__reference()->getMode() != Reference::ModeTwoway)
+ if(!_proxy->ice_isTwoway())
{
_childObserver.detach();
if(!_callback || !_callback->hasSentCallback())
@@ -595,6 +622,25 @@ IceInternal::OutgoingAsync::__finished(const Ice::Exception& exc)
}
void
+IceInternal::OutgoingAsync::__invokeExceptionAsync(const Ice::Exception& ex)
+{
+ if((_state & Done) == 0 && _handler)
+ {
+ //
+ // If we didn't finish a batch oneway or datagram request, we
+ // must notify the connection about that we give up ownership
+ // of the batch stream.
+ //
+ int mode = _proxy->__reference()->getMode();
+ if(mode == Reference::ModeBatchOneway || mode == Reference::ModeBatchDatagram)
+ {
+ _handler->abortBatchRequest();
+ }
+ }
+ AsyncResult::__invokeExceptionAsync(ex);
+}
+
+void
IceInternal::OutgoingAsync::__finished()
{
assert(_proxy->ice_isTwoway()); // Can only be called for twoways.
@@ -757,12 +803,21 @@ IceInternal::OutgoingAsync::__finished()
bool
IceInternal::OutgoingAsync::__invoke(bool synchronous)
{
+ const Reference::Mode mode = _proxy->__reference()->getMode();
+ if(mode == Reference::ModeBatchOneway || mode == Reference::ModeBatchDatagram)
+ {
+ _state |= Done | OK;
+ _handler->finishBatchRequest(&_os);
+ _observer.detach();
+ return true;
+ }
+
while(true)
{
try
{
_sent = false;
- _handler = _proxy->__getRequestHandler(true);
+ _handler = _proxy->__getRequestHandler();
AsyncStatus status = _handler->sendAsyncRequest(this);
if(status & AsyncStatusSent)
{
@@ -783,7 +838,7 @@ IceInternal::OutgoingAsync::__invoke(bool synchronous)
}
}
- if(_proxy->ice_isTwoway() || !(status & AsyncStatusSent))
+ if(mode == Reference::ModeTwoway || !(status & AsyncStatusSent))
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
if(!(_state & Done))
@@ -921,7 +976,7 @@ IceInternal::ProxyBatchOutgoingAsync::__invoke()
RequestHandlerPtr handler;
try
{
- handler = _proxy->__getRequestHandler(true);
+ handler = _proxy->__getRequestHandler();
AsyncStatus status = handler->sendAsyncRequest(this);
if(status & AsyncStatusSent)
{
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index 20b04eee154..720099b6927 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -1413,8 +1413,8 @@ IceProxy::Ice::Object::ice_getConnection()
RequestHandlerPtr handler;
try
{
- handler = __getRequestHandler(false);
- return handler->getConnection(true); // Wait for the connection to be established.
+ handler = __getRequestHandler();
+ return handler->waitForConnection(); // Wait for the connection to be established.
}
catch(const IceInternal::RetryException&)
{
@@ -1453,7 +1453,7 @@ IceProxy::Ice::Object::ice_getCachedConnection() const
{
try
{
- return __handler->getConnection(false);
+ return __handler->getConnection();
}
catch(const LocalException&)
{
@@ -1668,7 +1668,7 @@ operator<<(ostream& os, const ::IceProxy::Ice::Object& p)
}
::IceInternal::RequestHandlerPtr
-IceProxy::Ice::Object::__getRequestHandler(bool async)
+IceProxy::Ice::Object::__getRequestHandler()
{
if(_reference->getCacheConnection())
{
@@ -1677,12 +1677,11 @@ IceProxy::Ice::Object::__getRequestHandler(bool async)
{
return _requestHandler;
}
- _requestHandler = createRequestHandler(true); // async = true to avoid blocking with the proxy mutex locked.
+ _requestHandler = createRequestHandler(); // async = true to avoid blocking with the proxy mutex locked.
return _requestHandler;
}
- const Reference::Mode mode = _reference->getMode();
- return createRequestHandler(async || mode == Reference::ModeBatchOneway || mode == Reference::ModeBatchDatagram);
+ return createRequestHandler();
}
void
@@ -1705,7 +1704,7 @@ IceProxy::Ice::Object::__setRequestHandler(const ::IceInternal::RequestHandlerPt
// update the request handler. See bug ICE-5489 for reasons why
// this can be useful.
//
- if(previous->getConnection(false) == _requestHandler->getConnection(false))
+ if(previous->getConnection() == _requestHandler->getConnection())
{
_requestHandler = handler;
}
@@ -1725,7 +1724,7 @@ IceProxy::Ice::Object::__newInstance() const
}
RequestHandlerPtr
-IceProxy::Ice::Object::createRequestHandler(bool async)
+IceProxy::Ice::Object::createRequestHandler()
{
if(_reference->getCollocationOptimized())
{
@@ -1736,15 +1735,8 @@ IceProxy::Ice::Object::createRequestHandler(bool async)
}
}
- if(async)
- {
- ConnectRequestHandlerPtr handler = new ::IceInternal::ConnectRequestHandler(_reference, this);
- return handler->connect();
- }
- else
- {
- return new ::IceInternal::ConnectionRequestHandler(_reference, this);
- }
+ ConnectRequestHandlerPtr handler = new ::IceInternal::ConnectRequestHandler(_reference, this);
+ return handler->connect();
}
void
diff --git a/cpp/src/Ice/RequestHandler.h b/cpp/src/Ice/RequestHandler.h
index 23ce100c2e4..e2d83c63e20 100644
--- a/cpp/src/Ice/RequestHandler.h
+++ b/cpp/src/Ice/RequestHandler.h
@@ -70,7 +70,8 @@ public:
const ReferencePtr& getReference() const { return _reference; } // Inlined for performances.
- virtual Ice::ConnectionIPtr getConnection(bool) = 0;
+ virtual Ice::ConnectionIPtr getConnection() = 0;
+ virtual Ice::ConnectionIPtr waitForConnection() = 0;
protected:
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 80cc517890a..7f0ffd539a2 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -5159,138 +5159,33 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_out << nl << "checkTwowayOnly__(__" << op->name() << "_name);";
}
- _out << nl << "IceInternal.Outgoing og__ = getOutgoing(__" << op->name() << "_name, "
- << sliceModeToIceMode(op->sendMode()) << ", context__, explicitCtx__);";
- _out << nl << "try";
- _out << sb;
- if(!inParams.empty())
+
+ if(ret)
{
- _out << nl << "try";
- _out << sb;
- _out << nl << "IceInternal.BasicStream os__ = og__.startWriteParams(" << opFormatTypeToString(op) << ");";
- writeMarshalUnmarshalParams(inParams, 0, true);
- if(op->sendsClasses(false))
- {
- _out << nl << "os__.writePendingObjects();";
- }
- _out << nl << "og__.endWriteParams();";
- _out << eb;
- _out << nl << "catch(Ice.LocalException ex__)";
- _out << sb;
- _out << nl << "og__.abort(ex__);";
- _out << eb;
+ _out << nl << "return ";
}
else
{
- _out << nl << "og__.writeEmptyParams();";
+ _out << nl;
}
- if(!op->returnsData())
- {
- _out << "invoke__(og__);";
+ _out << "end_" << op->name() << "(";
+ if(!outParams.empty()) {
+ for(ParamDeclList::const_iterator p = outParams.begin(); p != outParams.end(); ++p) {
+ _out << "out " << fixId((*p)->name()) << ", ";
+ }
}
- else
+ _out << "begin_" << op->name() << "(";
+ if(!inParams.empty())
{
- _out << nl << "if(!og__.invoke())";
- _out << sb;
- //
- // The try/catch block is necessary because throwException()
- // can raise UserException.
- //
- _out << nl << "try";
- _out << sb;
- _out << nl << "og__.throwUserException();";
- _out << eb;
- for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t)
- {
- _out << nl << "catch(" << fixId((*t)->scoped()) << ')';
- _out << sb;
- _out << nl << "throw;";
- _out << eb;
- }
- _out << nl << "catch(Ice.UserException ex__)";
- _out << sb;
- _out << nl << "throw new Ice.UnknownUserException(ex__.ice_name(), ex__);";
- _out << eb;
- _out << eb;
- if(ret || !outParams.empty())
- {
- _out << nl << "IceInternal.BasicStream is__ = og__.startReadParams();";
- for(ParamDeclList::const_iterator pli = outParams.begin(); pli != outParams.end(); ++pli)
- {
- const bool isClass = isClassType((*pli)->type());
-
- if(!(*pli)->optional() && !isClass)
- {
- StructPtr st = StructPtr::dynamicCast((*pli)->type());
- if(st)
- {
- string param = fixId((*pli)->name());
- string typeS = typeToString(st, (*pli)->optional());
- if(isValueType(st))
- {
- _out << nl << param << " = new " << typeS << "();";
- }
- else
- {
- _out << nl << param << " = null;";
- }
- }
- }
- }
- if(ret)
- {
- string typeS = typeToString(ret, op->returnIsOptional());
- const bool isClass = isClassType(ret);
-
- _out << nl << typeS << " ret__;";
-
- if(op->returnIsOptional())
- {
- BuiltinPtr b = BuiltinPtr::dynamicCast(ret);
- if(!b || isClass)
- {
- _out << nl << "ret__ = new " << typeS << "();";
- }
- }
- else if(!isClass)
- {
- StructPtr st = StructPtr::dynamicCast(ret);
- if(st)
- {
- if(isValueType(st))
- {
- _out << nl << "ret__ = new " << typeS << "();";
- }
- else
- {
- _out << nl << "ret__ = null;";
- }
- }
- }
- }
- writeMarshalUnmarshalParams(outParams, op, false);
- if(op->returnsClasses(false))
- {
- _out << nl << "is__.readPendingObjects();";
- }
- _out << nl << "og__.endReadParams();";
- writePostUnmarshalParams(outParams, op);
- if(ret)
- {
- _out << nl << "return ret__;";
- }
+ for(ParamDeclList::const_iterator p = inParams.begin(); p != inParams.end(); ++p) {
+ _out << fixId((*p)->name()) << ", ";
}
}
- _out << eb;
- _out << nl << "finally";
- _out << sb;
- _out << nl << "reclaimOutgoing(og__);";
- _out << eb;
-
+ _out << "context__, explicitCtx__, true, null, null));";
_out << eb;
}
-
+
if(!ops.empty())
{
_out << sp << nl << "#endregion"; // Synchronous operations
@@ -5336,7 +5231,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << sp;
_out << nl << "public Ice.AsyncResult<" << delType << "> begin_" << opName << spar << paramsAMI << epar;
_out << sb;
- _out << nl << "return begin_" << opName << spar << argsAMI << "null" << "false" << "null" << "null"
+ _out << nl << "return begin_" << opName << spar << argsAMI << "null" << "false" << "false" << "null" << "null"
<< epar << ';';
_out << eb;
@@ -5346,7 +5241,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << nl << "public Ice.AsyncResult<" << delType << "> begin_" << opName << spar << paramsAMI
<< "_System.Collections.Generic.Dictionary<string, string> ctx__" << epar;
_out << sb;
- _out << nl << "return begin_" << opName << spar << argsAMI << "ctx__" << "true" << "null" << "null"
+ _out << nl << "return begin_" << opName << spar << argsAMI << "ctx__" << "true" << "false" << "null" << "null"
<< epar << ';';
_out << eb;
@@ -5354,7 +5249,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << nl << "public Ice.AsyncResult begin_" << opName << spar << paramsAMI
<< "Ice.AsyncCallback cb__" << "object cookie__" << epar;
_out << sb;
- _out << nl << "return begin_" << opName << spar << argsAMI << "null" << "false" << "cb__" << "cookie__"
+ _out << nl << "return begin_" << opName << spar << argsAMI << "null" << "false" << "false" << "cb__" << "cookie__"
<< epar << ';';
_out << eb;
@@ -5364,7 +5259,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
<< "_System.Collections.Generic.Dictionary<string, string> ctx__" << "Ice.AsyncCallback cb__"
<< "object cookie__" << epar;
_out << sb;
- _out << nl << "return begin_" << opName << spar << argsAMI << "ctx__" << "true" << "cb__" << "cookie__"
+ _out << nl << "return begin_" << opName << spar << argsAMI << "ctx__" << "true" << "false" << "cb__" << "cookie__"
<< epar << ';';
_out << eb;
@@ -5382,8 +5277,12 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
if(op->returnsData())
{
_out << nl << "IceInternal.OutgoingAsync outAsync__ = (IceInternal.OutgoingAsync)r__;";
- _out << nl << "IceInternal.OutgoingAsync.check__(outAsync__, this, " << flatName << ");";
- _out << nl << "if(!outAsync__.wait__())";
+ _out << nl << "IceInternal.OutgoingAsync.check(outAsync__, this, " << flatName << ");";
+
+ _out << nl << "try";
+ _out << sb;
+
+ _out << nl << "if(!outAsync__.wait())";
_out << sb;
ExceptionList throws = op->throws();
@@ -5404,7 +5303,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << nl << "try";
_out << sb;
- _out << nl << "outAsync__.throwUserException__();";
+ _out << nl << "outAsync__.throwUserException();";
_out << eb;
for(ExceptionList::const_iterator r = throws.begin(); r != throws.end(); ++r)
{
@@ -5425,7 +5324,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_out << nl << retS << " ret__;";
}
- _out << nl << "IceInternal.BasicStream is__ = outAsync__.startReadParams__();";
+ _out << nl << "IceInternal.BasicStream is__ = outAsync__.startReadParams();";
for(ParamDeclList::const_iterator pli = outParams.begin(); pli != outParams.end(); ++pli)
{
string param = fixId((*pli)->name());
@@ -5474,7 +5373,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_out << nl << "is__.readPendingObjects();";
}
- _out << nl << "outAsync__.endReadParams__();";
+ _out << nl << "outAsync__.endReadParams();";
writePostUnmarshalParams(outParams, op);
if(ret)
{
@@ -5483,8 +5382,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
}
else
{
- _out << nl << "outAsync__.readEmptyParams__();";
+ _out << nl << "outAsync__.readEmptyParams();";
}
+
+ _out << eb;
+ _out << nl << "finally";
+ _out << sb;
+ _out << nl << "outAsync__.cacheMessageBuffers();";
+ _out << eb;
}
else
{
@@ -5498,19 +5403,19 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << sp;
_out << nl << "private Ice.AsyncResult<" << delType << "> begin_" << opName << spar << paramsAMI
<< "_System.Collections.Generic.Dictionary<string, string> ctx__"
- << "bool explicitContext__" << "Ice.AsyncCallback cb__" << "object cookie__" << epar;
+ << "bool explicitContext__" << "bool synchronous__" << "Ice.AsyncCallback cb__" << "object cookie__" << epar;
_out << sb;
if(op->returnsData())
{
_out << nl << "checkAsyncTwowayOnly__(" << flatName << ");";
_out << nl << "IceInternal.TwowayOutgoingAsync<" << delType << "> result__ = "
- << " new IceInternal.TwowayOutgoingAsync<" << delType << ">(this, " << flatName << ", " << op->name()
+ << " getTwowayOutgoingAsync<" << delType << ">(" << flatName << ", " << op->name()
<< "_completed__";
}
else
{
_out << nl << "IceInternal.OnewayOutgoingAsync<" << delType << "> result__ = "
- << "new IceInternal.OnewayOutgoingAsync<" << delType << ">(this, " << flatName << ", " << op->name()
+ << "getOnewayOutgoingAsync<" << delType << ">(" << flatName << ", " << op->name()
<< "_completed__";
}
_out << ", cookie__);";
@@ -5520,28 +5425,30 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << eb;
_out << nl << "try";
_out << sb;
- _out << nl << "result__.prepare__(" << flatName << ", "
- << sliceModeToIceMode(op->sendMode()) << ", ctx__, explicitContext__);";
+ _out << nl << "result__.prepare(" << flatName << ", "
+ << sliceModeToIceMode(op->sendMode()) << ", ctx__, explicitContext__, synchronous__);";
+
if(!inParams.empty())
{
- _out << nl << "IceInternal.BasicStream os__ = result__.startWriteParams__("
+ _out << nl << "IceInternal.BasicStream os__ = result__.startWriteParams("
<< opFormatTypeToString(op) << ");";
writeMarshalUnmarshalParams(inParams, 0, true);
if(op->sendsClasses(false))
{
_out << nl << "os__.writePendingObjects();";
}
- _out << nl << "result__.endWriteParams__();";
+ _out << nl << "result__.endWriteParams();";
}
else
{
- _out << nl << "result__.writeEmptyParams__();";
+ _out << nl << "result__.writeEmptyParams();";
}
- _out << nl << "result__.invoke__(true);";
+
+ _out << nl << "result__.invoke(true);";
_out << eb;
_out << nl << "catch(Ice.Exception ex__)";
_out << sb;
- _out << nl << "result__.invokeExceptionAsync__(ex__);";
+ _out << nl << "result__.invokeExceptionAsync(ex__);";
_out << eb;
_out << nl << "return result__;";
_out << eb;
@@ -5642,7 +5549,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << sb;
_out << nl << "result__ = new IceInternal.TwowayOutgoingAsync<" << delType << ">(this, "
<< flatName << ", " << op->name() << "_completed__, null);";
- _out << nl << "((IceInternal.OutgoingAsyncBase)result__).invokeExceptionAsync__(ex);";
+ _out << nl << "((IceInternal.OutgoingAsyncBase)result__).invokeExceptionAsync(ex);";
_out << eb;
}
else
@@ -5676,7 +5583,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << sb;
_out << nl << "result__ = new IceInternal.TwowayOutgoingAsync<" << delType << ">(this, "
<< flatName << ", " << op->name() << "_completed__, null);";
- _out << nl << "((IceInternal.OutgoingAsyncBase)result__).invokeExceptionAsync__(ex);";
+ _out << nl << "((IceInternal.OutgoingAsyncBase)result__).invokeExceptionAsync(ex);";
_out << eb;
}
else
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 48f3af304c8..9de67726eb9 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -529,6 +529,7 @@ Slice::JavaVisitor::getArgsAsyncLambda(const OperationPtr& op, const string& pac
vector<string> args = getInOutArgs(op, InParam);
args.push_back(context ? "__ctx" : "null");
args.push_back(context ? "true" : "false");
+ args.push_back("false"); // __synchronous
args.push_back("__responseCb");
if(!op->throws().empty())
{
@@ -4733,18 +4734,22 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sp;
writeDocCommentAsync(out, op, OutParam);
- out << nl << "public " << retS << " end_" << op->name() << spar << outParams << "Ice.AsyncResult __result"
+ out << nl << "public " << retS << " end_" << op->name() << spar << outParams << "Ice.AsyncResult __iresult"
<< epar;
writeThrowsClause(package, throws);
out << sb;
if(op->returnsData())
{
- out << nl << "Ice.AsyncResult.__check(__result, this, __" << op->name() << "_name);";
+ out << nl << "IceInternal.AsyncResultI __result = (IceInternal.AsyncResultI)__iresult;";
+ out << nl << "IceInternal.AsyncResultI.check(__result, this, __" << op->name() << "_name);";
+ out << nl << "try";
+ out << sb;
+
out << nl << "if(!__result.__wait())";
out << sb;
out << nl << "try";
out << sb;
- out << nl << "__result.__throwUserException();";
+ out << nl << "__result.throwUserException();";
out << eb;
//
// Arrange exceptions into most-derived to least-derived order. If we don't
@@ -4772,7 +4777,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
if(ret || !outParams.empty())
{
- out << nl << "IceInternal.BasicStream __is = __result.__startReadParams();";
+ out << nl << "IceInternal.BasicStream __is = __result.startReadParams();";
const ParamDeclList paramList = op->parameters();
ParamDeclList pl;
for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
@@ -4787,11 +4792,11 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
{
out << nl << "__is.readPendingObjects();";
}
- out << nl << "__result.__endReadParams();";
+ out << nl << "__result.endReadParams();";
}
else
{
- out << nl << "__result.__readEmptyParams();";
+ out << nl << "__result.readEmptyParams();";
}
if(ret)
@@ -4807,10 +4812,19 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << nl << "return __ret;";
}
}
+
+ out << eb;
+ out << nl << "finally";
+ out << sb;
+ out << nl << "if(__result != null)";
+ out << sb;
+ out << nl << "__result.cacheMessageBuffers();";
+ out << eb;
+ out << eb;
}
else
{
- out << nl << "__end(__result, __" << op->name() << "_name);";
+ out << nl << "__end(__iresult, __" << op->name() << "_name);";
}
out << eb;
@@ -4921,18 +4935,19 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sb;
out << nl << "__checkTwowayOnly(__" << op->name() << "_name);";
out << nl << "__r = begin_" << op->name() << spar << argsAMI << "null" << "false"
- << "__cb" << epar << ';';
+ << "false" << "__cb" << epar << ';';
out << eb;
out << nl << "catch(Ice.TwowayOnlyException ex)";
out << sb;
- out << nl << "__r = new IceInternal.OutgoingAsync(this, __" << op->name() << "_name, __cb);";
- out << nl << "__r.__invokeExceptionAsync(ex);";
+ out << nl << "IceInternal.OutgoingAsync __r2 = getOutgoingAsync(__" << op->name() << "_name, __cb);";
+ out << nl << "__r = __r2;";
+ out << nl << "__r2.invokeExceptionAsync(ex);";
out << eb;
}
else
{
out << nl << "Ice.AsyncResult __r = begin_" << op->name() << spar << argsAMI << "null" << "false"
- << "__cb" << epar << ';';
+ << "false" << "__cb" << epar << ';';
}
out << nl << "return __r.sentSynchronously();";
out << eb;
@@ -4948,18 +4963,19 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sb;
out << nl << "__checkTwowayOnly(__" << op->name() << "_name);";
out << nl << "__r = begin_" << op->name() << spar << argsAMI << "__ctx" << "true"
- << "__cb" << epar << ';';
+ << "false" << "__cb" << epar << ';';
out << eb;
out << nl << "catch(Ice.TwowayOnlyException ex)";
out << sb;
- out << nl << "__r = new IceInternal.OutgoingAsync(this, __" << op->name() << "_name, __cb);";
- out << nl << "__r.__invokeExceptionAsync(ex);";
+ out << nl << "IceInternal.OutgoingAsync __r2 = getOutgoingAsync(__" << op->name() << "_name, __cb);";
+ out << nl << "__r = __r2;";
+ out << nl << "__r2.invokeExceptionAsync(ex);";
out << eb;
}
else
{
out << nl << "Ice.AsyncResult __r = begin_" << op->name() << spar << argsAMI << "__ctx" << "true"
- << "__cb" << epar << ';';
+ << "false" << "__cb" << epar << ';';
}
out << nl << "return __r.sentSynchronously();";
out << eb;
@@ -4968,123 +4984,39 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sp << nl << "public static " << name << "Prx checkedCast(Ice.ObjectPrx __obj)";
out << sb;
- out << nl << name << "Prx __d = null;";
- out << nl << "if(__obj != null)";
- out << sb;
- out << nl << "if(__obj instanceof " << name << "Prx)";
- out << sb;
- out << nl << "__d = (" << name << "Prx)__obj;";
- out << eb;
- out << nl << "else";
- out << sb;
- out << nl << "if(__obj.ice_isA(ice_staticId()))";
- out << sb;
- out << nl << name << "PrxHelper __h = new " << name << "PrxHelper();";
- out << nl << "__h.__copyFrom(__obj);";
- out << nl << "__d = __h;";
- out << eb;
- out << eb;
- out << eb;
- out << nl << "return __d;";
+ out << nl << "return checkedCastImpl(__obj, ice_staticId(), " << name << "Prx.class, "
+ << name << "PrxHelper.class);";
out << eb;
out << sp << nl << "public static " << name << "Prx checkedCast(Ice.ObjectPrx __obj, " << contextParam << ')';
out << sb;
- out << nl << name << "Prx __d = null;";
- out << nl << "if(__obj != null)";
- out << sb;
- out << nl << "if(__obj instanceof " << name << "Prx)";
- out << sb;
- out << nl << "__d = (" << name << "Prx)__obj;";
- out << eb;
- out << nl << "else";
- out << sb;
- out << nl << "if(__obj.ice_isA(ice_staticId(), __ctx))";
- out << sb;
- out << nl << name << "PrxHelper __h = new " << name << "PrxHelper();";
- out << nl << "__h.__copyFrom(__obj);";
- out << nl << "__d = __h;";
- out << eb;
- out << eb;
- out << eb;
- out << nl << "return __d;";
+ out << nl << "return checkedCastImpl(__obj, __ctx, ice_staticId(), " << name
+ << "Prx.class, " << name << "PrxHelper.class);";
out << eb;
out << sp << nl << "public static " << name << "Prx checkedCast(Ice.ObjectPrx __obj, String __facet)";
out << sb;
- out << nl << name << "Prx __d = null;";
- out << nl << "if(__obj != null)";
- out << sb;
- out << nl << "Ice.ObjectPrx __bb = __obj.ice_facet(__facet);";
- out << nl << "try";
- out << sb;
- out << nl << "if(__bb.ice_isA(ice_staticId()))";
- out << sb;
- out << nl << name << "PrxHelper __h = new " << name << "PrxHelper();";
- out << nl << "__h.__copyFrom(__bb);";
- out << nl << "__d = __h;";
- out << eb;
- out << eb;
- out << nl << "catch(Ice.FacetNotExistException ex)";
- out << sb;
- out << eb;
- out << eb;
- out << nl << "return __d;";
+ out << nl << "return checkedCastImpl(__obj, __facet, ice_staticId(), " << name
+ << "Prx.class, " << name << "PrxHelper.class);";
out << eb;
out << sp << nl << "public static " << name << "Prx checkedCast(Ice.ObjectPrx __obj, String __facet, "
<< contextParam << ')';
out << sb;
- out << nl << name << "Prx __d = null;";
- out << nl << "if(__obj != null)";
- out << sb;
- out << nl << "Ice.ObjectPrx __bb = __obj.ice_facet(__facet);";
- out << nl << "try";
- out << sb;
- out << nl << "if(__bb.ice_isA(ice_staticId(), __ctx))";
- out << sb;
- out << nl << name << "PrxHelper __h = new " << name << "PrxHelper();";
- out << nl << "__h.__copyFrom(__bb);";
- out << nl << "__d = __h;";
- out << eb;
- out << eb;
- out << nl << "catch(Ice.FacetNotExistException ex)";
- out << sb;
- out << eb;
- out << eb;
- out << nl << "return __d;";
+ out << nl << "return checkedCastImpl(__obj, __facet, __ctx, ice_staticId(), " << name
+ << "Prx.class, " << name << "PrxHelper.class);";
out << eb;
out << sp << nl << "public static " << name << "Prx uncheckedCast(Ice.ObjectPrx __obj)";
out << sb;
- out << nl << name << "Prx __d = null;";
- out << nl << "if(__obj != null)";
- out << sb;
- out << nl << "if(__obj instanceof " << name << "Prx)";
- out << sb;
- out << nl << "__d = (" << name << "Prx)__obj;";
- out << eb;
- out << nl << "else";
- out << sb;
- out << nl << name << "PrxHelper __h = new " << name << "PrxHelper();";
- out << nl << "__h.__copyFrom(__obj);";
- out << nl << "__d = __h;";
- out << eb;
- out << eb;
- out << nl << "return __d;";
+ out << nl << "return uncheckedCastImpl(__obj, " << name << "Prx.class, " << name
+ << "PrxHelper.class);";
out << eb;
out << sp << nl << "public static " << name << "Prx uncheckedCast(Ice.ObjectPrx __obj, String __facet)";
out << sb;
- out << nl << name << "Prx __d = null;";
- out << nl << "if(__obj != null)";
- out << sb;
- out << nl << "Ice.ObjectPrx __bb = __obj.ice_facet(__facet);";
- out << nl << name << "PrxHelper __h = new " << name << "PrxHelper();";
- out << nl << "__h.__copyFrom(__bb);";
- out << nl << "__d = __h;";
- out << eb;
- out << nl << "return __d;";
+ out << nl << "return uncheckedCastImpl(__obj, __facet, " << name << "Prx.class, " << name
+ << "PrxHelper.class);";
out << eb;
ClassList allBases = p->allBases();
@@ -5494,8 +5426,6 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
vector<string> params = getParamsProxy(op, package, false, optionalMapping);
vector<string> args = getArgs(op);
- int iter = 0;
-
ParamDeclList inParams;
ParamDeclList outParams;
ParamDeclList paramList = op->parameters();
@@ -5553,91 +5483,38 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
<< explicitContextParam << epar;
writeThrowsClause(package, throws);
out << sb;
+
+ // This code replaces the synchronous calls with chained AMI calls.
if(op->returnsData())
{
out << nl << "__checkTwowayOnly(__" << op->name() << "_name);";
}
- out << nl << "IceInternal.Outgoing __og = getOutgoing(__" << op->name() << "_name, " <<
- sliceModeToIceMode(op->sendMode()) << ", __ctx, __explicitCtx);";
- out << nl << "try";
- out << sb;
- if(!inParams.empty())
+ if(ret)
{
- out << nl << "try";
- out << sb;
- out << nl << "IceInternal.BasicStream __os = __og.startWriteParams(" << opFormatTypeToString(op) << ");";
- writeMarshalUnmarshalParams(out, package, inParams, 0, iter, true, optionalMapping);
- if(op->sendsClasses(false))
- {
- out << nl << "__os.writePendingObjects();";
- }
- out << nl << "__og.endWriteParams();";
- out << eb;
- out << nl << "catch(Ice.LocalException __ex)";
- out << sb;
- out << nl << "__og.abort(__ex);";
- out << eb;
+ out << nl << "return ";
}
else
{
- out << nl << "__og.writeEmptyParams();";
+ out << nl;
}
- if(!op->returnsData())
- {
- out << nl << "__invoke(__og);";
+ out << "end_" << op->name() << "(";
+ vector<string> inOutArgs = getInOutArgs(op, OutParam);
+ if(!inOutArgs.empty()) {
+ for(vector<string>::const_iterator p = inOutArgs.begin(); p != inOutArgs.end(); ++p) {
+ out << *p << ", ";
+ }
}
- else
+ vector<string> inArgs = getInOutArgs(op, InParam);
+ out << "begin_" << op->name() << "(";
+ if(!inArgs.empty())
{
- out << nl << "if(!__og.invoke())";
- out << sb;
- out << nl << "try";
- out << sb;
- out << nl << "__og.throwUserException();";
- out << eb;
- for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t)
- {
- out << nl << "catch(" << getAbsolute(*t, package) << " __ex)";
- out << sb;
- out << nl << "throw __ex;";
- out << eb;
- }
- out << nl << "catch(Ice.UserException __ex)";
- out << sb;
- out << nl << "throw new Ice.UnknownUserException(__ex.ice_name(), __ex);";
- out << eb;
- out << eb;
- if(ret || !outParams.empty())
- {
- out << nl << "IceInternal.BasicStream __is = __og.startReadParams();";
- writeMarshalUnmarshalParams(out, package, outParams, op, iter, false, true);
- if(op->returnsClasses(false))
- {
- out << nl << "__is.readPendingObjects();";
- }
- out << nl << "__og.endReadParams();";
- }
-
- if(ret)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
- if(!op->returnIsOptional() &&
- ((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret)))
- {
- out << nl << "return __ret.value;";
- }
- else
- {
- out << nl << "return __ret;";
- }
+ for(vector<string>::const_iterator p = inArgs.begin(); p != inArgs.end(); ++p) {
+ out << *p << ", ";
}
}
- out << eb;
- out << nl << "finally";
- out << sb;
- out << nl << "reclaimOutgoing(__og);";
- out << eb;
+ out << "__ctx, __explicitCtx, true, null));";
out << eb;
{
@@ -5657,21 +5534,21 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
writeDocCommentAsync(out, op, InParam);
out << nl << "public Ice.AsyncResult begin_" << op->name() << spar << inParams << epar;
out << sb;
- out << nl << "return begin_" << op->name() << spar << inArgs << "null" << "false" << "null" << epar << ';';
+ out << nl << "return begin_" << op->name() << spar << inArgs << "null" << "false" << "false" << "null" << epar << ';';
out << eb;
out << sp;
writeDocCommentAsync(out, op, InParam, contextDoc);
out << nl << "public Ice.AsyncResult begin_" << op->name() << spar << inParams << contextParam << epar;
out << sb;
- out << nl << "return begin_" << op->name() << spar << inArgs << "__ctx" << "true" << "null" << epar << ';';
+ out << nl << "return begin_" << op->name() << spar << inArgs << "__ctx" << "true" << "false" << "null" << epar << ';';
out << eb;
out << sp;
writeDocCommentAsync(out, op, InParam);
out << nl << "public Ice.AsyncResult begin_" << op->name() << spar << inParams << callbackParam << epar;
out << sb;
- out << nl << "return begin_" << op->name() << spar << inArgs << "null" << "false" << "__cb" << epar << ';';
+ out << nl << "return begin_" << op->name() << spar << inArgs << "null" << "false" << "false" << "__cb" << epar << ';';
out << eb;
out << sp;
@@ -5679,7 +5556,7 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
out << nl << "public Ice.AsyncResult begin_" << op->name() << spar << inParams << contextParam
<< callbackParam << epar;
out << sb;
- out << nl << "return begin_" << op->name() << spar << inArgs << "__ctx" << "true" << "__cb" << epar << ';';
+ out << nl << "return begin_" << op->name() << spar << inArgs << "__ctx" << "true" << "false" << "__cb" << epar << ';';
out << eb;
//
@@ -5701,7 +5578,7 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
out << nl << "public Ice.AsyncResult begin_" << op->name() << spar << inParams << typeSafeCallbackParam
<< epar;
out << sb;
- out << nl << "return begin_" << op->name() << spar << inArgs << "null" << "false" << "__cb" << epar << ';';
+ out << nl << "return begin_" << op->name() << spar << inArgs << "null" << "false" << "false" << "__cb" << epar << ';';
out << eb;
out << sp;
@@ -5709,7 +5586,7 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
out << nl << "public Ice.AsyncResult begin_" << op->name() << spar << inParams << contextParam
<< typeSafeCallbackParam << epar;
out << sb;
- out << nl << "return begin_" << op->name() << spar << inArgs << "__ctx" << "true" << "__cb" << epar << ';';
+ out << nl << "return begin_" << op->name() << spar << inArgs << "__ctx" << "true" << "false" << "__cb" << epar << ';';
out << eb;
//
@@ -5747,6 +5624,7 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
vector<string> params = inParams;
params.push_back(contextParam);
params.push_back("boolean __explicitCtx");
+ params.push_back("boolean __synchronous");
vector<string> asyncParams = getParamsAsyncLambda(op, package, false, true, optionalMapping, false);
copy(asyncParams.begin(), asyncParams.end(), back_inserter(params));
@@ -5762,6 +5640,7 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
params = getInOutArgs(op, InParam);
params.push_back("__ctx");
params.push_back("__explicitCtx");
+ params.push_back("__synchronous");
params.push_back("new IceInternal.Functional_OnewayCallback(__responseCb, __exceptionCb, __sentCb)");
out << nl << "return begin_" << op->name();
writeParamList(out, params);
@@ -5819,6 +5698,7 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
out << nl << "return begin_" << op->name() << spar << getInOutArgs(op, InParam) << "__ctx"
<< "__explicitCtx"
+ << "__synchronous"
<< (throws.empty() ? "new CB(__responseCb, __exceptionCb, __sentCb)" :
"new CB(__responseCb, __userExceptionCb, __exceptionCb, __sentCb)")
<< epar << ';';
@@ -5828,6 +5708,7 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
params = getInOutArgs(op, InParam);
params.push_back("__ctx");
params.push_back("__explicitCtx");
+ params.push_back("__synchronous");
const string baseClass = getAsyncCallbackBaseClass(op, true);
out << nl << "return begin_" << op->name();
@@ -5853,6 +5734,7 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
params = inParams;
params.push_back(contextParam);
params.push_back("boolean __explicitCtx");
+ params.push_back("boolean __synchronous");
params.push_back("IceInternal.CallbackBase __cb");
out << sp;
@@ -5863,16 +5745,18 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
{
out << nl << "__checkAsyncTwowayOnly(__" << op->name() << "_name);";
}
- out << nl << "IceInternal.OutgoingAsync __result = new IceInternal.OutgoingAsync(this, __" << op->name()
+ out << nl << "IceInternal.OutgoingAsync __result = getOutgoingAsync(__" << op->name()
<< "_name, __cb);";
out << nl << "try";
out << sb;
- out << nl << "__result.__prepare(__" << op->name() << "_name, " << sliceModeToIceMode(op->sendMode())
- << ", __ctx, __explicitCtx);";
+
+ out << nl << "__result.prepare(__" << op->name() << "_name, " << sliceModeToIceMode(op->sendMode())
+ << ", __ctx, __explicitCtx, __synchronous);";
+
iter = 0;
if(!inArgs.empty())
{
- out << nl << "IceInternal.BasicStream __os = __result.__startWriteParams("
+ out << nl << "IceInternal.BasicStream __os = __result.startWriteParams("
<< opFormatTypeToString(op) << ");";
ParamDeclList pl;
for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
@@ -5887,17 +5771,18 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa
{
out << nl << "__os.writePendingObjects();";
}
- out << nl << "__result.__endWriteParams();";
+ out << nl << "__result.endWriteParams();";
}
else
{
- out << nl << "__result.__writeEmptyParams();";
+ out << nl << "__result.writeEmptyParams();";
}
- out << nl << "__result.__invoke(true);";
+
+ out << nl << "__result.invoke(true);";
out << eb;
out << nl << "catch(Ice.Exception __ex)";
out << sb;
- out << nl << "__result.__invokeExceptionAsync(__ex);";
+ out << nl << "__result.invokeExceptionAsync(__ex);";
out << eb;
out << nl << "return __result;";
out << eb;
diff --git a/cpp/test/Ice/metrics/AllTests.cpp b/cpp/test/Ice/metrics/AllTests.cpp
index 7fb13af91e1..3205a0b9d53 100644
--- a/cpp/test/Ice/metrics/AllTests.cpp
+++ b/cpp/test/Ice/metrics/AllTests.cpp
@@ -130,19 +130,21 @@ public:
void
waitForUpdate()
{
- Lock sync(*this);
- while(!_updated)
- {
- wait();
- }
- if(_serverProps->ice_getConnection())
{
- // Ensure that the previous updates were committed, the setProperties call returns before
- // notifying the callbacks so to ensure all the update callbacks have be notified we call
- // a second time, this will block until all the notifications from the first update have
- // completed.
- _serverProps->setProperties(Ice::PropertyDict());
+ Lock sync(*this);
+ while(!_updated)
+ {
+ wait();
+ }
}
+
+ // Ensure that the previous updates were committed, the setProperties call returns before
+ // notifying the callbacks so to ensure all the update callbacks have be notified we call
+ // a second time, this will block until all the notifications from the first update have
+ // completed.
+ _serverProps->setProperties(Ice::PropertyDict());
+
+ Lock sync(*this);
_updated = false;
}
@@ -1080,6 +1082,52 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry2", "", op);
testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry3", "", op);
+ //
+ // Tests with oneway
+ //
+ props["IceMX.Metrics.View.Map.Invocation.GroupBy"] = "operation";
+ props["IceMX.Metrics.View.Map.Invocation.Map.Remote.GroupBy"] = "localPort";
+ updateProps(clientProps, serverProps, update, props, "Invocation");
+
+ MetricsPrx metricsOneway = metrics->ice_oneway();
+ metricsOneway->op();
+ metricsOneway->end_op(metricsOneway->begin_op());
+ metricsOneway->begin_op(newCallback_Metrics_op(cb, &Callback::response, &Callback::exception));
+
+ map = toMap(clientMetrics->getMetricsView("View", timestamp)["Invocation"]);
+ test(map.size() == 1);
+
+ im1 = IceMX::InvocationMetricsPtr::dynamicCast(map["op"]);
+ test(im1->current <= 1 && im1->total == 3 && im1->failures == 0 && im1->retry == 0);
+ test(!collocated ? (im1->remotes.size() == 1) : (im1->collocated.size() == 1));
+ rim1 = IceMX::ChildInvocationMetricsPtr::dynamicCast(!collocated ? im1->remotes[0] : im1->collocated[0]);
+ test(rim1->current <= 1 && rim1->total == 3 && rim1->failures == 0);
+ test(rim1->size == 63 && rim1->replySize == 0);
+
+ testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "oneway", InvokeOp(metricsOneway));
+
+ //
+ // Tests with batch oneway
+ //
+ props["IceMX.Metrics.View.Map.Invocation.GroupBy"] = "operation";
+ props["IceMX.Metrics.View.Map.Invocation.Map.Remote.GroupBy"] = "localPort";
+ updateProps(clientProps, serverProps, update, props, "Invocation");
+
+ MetricsPrx metricsBatchOneway = metrics->ice_batchOneway();
+ metricsBatchOneway->op();
+ //metricsBatchOneway->end_op(metricsOneway->begin_op());
+ //metricsBatchOneway->begin_op(newCallback_Metrics_op(cb, &Callback::response, &Callback::exception));
+
+ map = toMap(clientMetrics->getMetricsView("View", timestamp)["Invocation"]);
+ test(map.size() == 1);
+
+ im1 = IceMX::InvocationMetricsPtr::dynamicCast(map["op"]);
+ test(im1->current == 0 && im1->total == 1 && im1->failures == 0 && im1->retry == 0);
+ test(im1->remotes.size() == 0);
+
+ testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "batch-oneway",
+ InvokeOp(metricsBatchOneway));
+
cout << "ok" << endl;
cout << "testing metrics view enable/disable..." << flush;
diff --git a/cpp/test/Ice/operations/AllTests.cpp b/cpp/test/Ice/operations/AllTests.cpp
index 318ea398451..62ca357166d 100644
--- a/cpp/test/Ice/operations/AllTests.cpp
+++ b/cpp/test/Ice/operations/AllTests.cpp
@@ -62,5 +62,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
batchOneways(derived);
cout << "ok" << endl;
+ cout << "testing batch AMI oneway operations... " << flush;
+ void batchOnewaysAMI(const Test::MyClassPrx&);
+ batchOnewaysAMI(cl);
+ batchOnewaysAMI(derived);
+ cout << "ok" << endl;
+
return cl;
}
diff --git a/cpp/test/Ice/operations/BatchOneways.cpp b/cpp/test/Ice/operations/BatchOneways.cpp
index 9916a7f1243..c2217d67f5f 100644
--- a/cpp/test/Ice/operations/BatchOneways.cpp
+++ b/cpp/test/Ice/operations/BatchOneways.cpp
@@ -48,7 +48,6 @@ batchOneways(const Test::MyClassPrx& p)
Test::MyClassPrx batch = Test::MyClassPrx::uncheckedCast(p->ice_batchOneway());
batch->ice_flushBatchRequests();
- batch->end_ice_flushBatchRequests(batch->begin_ice_flushBatchRequests());
int i;
diff --git a/cpp/test/Ice/operations/BatchOnewaysAMI.cpp b/cpp/test/Ice/operations/BatchOnewaysAMI.cpp
new file mode 100644
index 00000000000..a722b7868ee
--- /dev/null
+++ b/cpp/test/Ice/operations/BatchOnewaysAMI.cpp
@@ -0,0 +1,206 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <Ice/Ice.h>
+#include <TestCommon.h>
+#include <Test.h>
+
+using namespace std;
+
+namespace
+{
+
+class Callback : public IceUtil::Monitor<IceUtil::Mutex>, public IceUtil::Shared
+{
+public:
+
+ Callback() :
+ _called(false)
+ {
+ }
+
+ virtual ~Callback()
+ {
+ }
+
+ void check()
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ while(!_called)
+ {
+ wait();
+ }
+ _called = false;
+ }
+
+ void called()
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ assert(!_called);
+ _called = true;
+ notify();
+ }
+
+private:
+
+ bool _called;
+};
+typedef IceUtil::Handle<Callback> CallbackPtr;
+
+class Callback_ByteSOneway1 : public IceUtil::Shared
+{
+ CallbackPtr _cb;
+
+public:
+
+ Callback_ByteSOneway1(const CallbackPtr& cb) : _cb(cb)
+ {
+ }
+
+ void response()
+ {
+ _cb->called();
+ }
+
+ void exception(const ::Ice::Exception&)
+ {
+ test(false);
+ }
+};
+
+class Callback_ByteSOneway2 : public IceUtil::Shared
+{
+ CallbackPtr _cb;
+
+public:
+
+ Callback_ByteSOneway2(const CallbackPtr& cb) : _cb(cb)
+ {
+ }
+
+ void response()
+ {
+ test(false);
+ }
+
+ void exception(const ::Ice::Exception& ex)
+ {
+ test(dynamic_cast<const ::Ice::MemoryLimitException*>(&ex));
+ _cb->called();
+ }
+};
+
+class Callback_ByteSOneway3 : public IceUtil::Shared
+{
+public:
+
+ void response()
+ {
+ }
+
+ void exception(const ::Ice::Exception&)
+ {
+ test(false);
+ }
+};
+
+class Callback_ping : public IceUtil::Shared
+{
+ CallbackPtr _cb;
+
+public:
+
+ Callback_ping(const CallbackPtr& cb) : _cb(cb)
+ {
+ }
+
+ void response()
+ {
+ test(false);
+ }
+
+ void exception(const ::Ice::Exception& ex)
+ {
+ test(dynamic_cast<const Ice::CloseConnectionException*>(&ex));
+ _cb->called();
+ }
+};
+}
+
+void
+batchOnewaysAMI(const Test::MyClassPrx& p)
+{
+ const Test::ByteS bs1(10 * 1024);
+ const Test::ByteS bs2(99 * 1024);
+ const Test::ByteS bs3(100 * 1024);
+
+ CallbackPtr cb = new Callback();
+ p->begin_opByteSOneway(bs1, Test::newCallback_MyClass_opByteSOneway(new Callback_ByteSOneway1(cb),
+ &Callback_ByteSOneway1::response, &Callback_ByteSOneway1::exception));
+ cb->check();
+
+ p->begin_opByteSOneway(bs2, Test::newCallback_MyClass_opByteSOneway(new Callback_ByteSOneway1(cb),
+ &Callback_ByteSOneway1::response, &Callback_ByteSOneway1::exception));
+ cb->check();
+
+ p->begin_opByteSOneway(bs3, Test::newCallback_MyClass_opByteSOneway(new Callback_ByteSOneway2(cb),
+ &Callback_ByteSOneway2::response, &Callback_ByteSOneway2::exception));
+ cb->check();
+
+ Test::MyClassPrx batch = Test::MyClassPrx::uncheckedCast(p->ice_batchOneway());
+ batch->end_ice_flushBatchRequests(batch->begin_ice_flushBatchRequests());
+
+ int i;
+
+ for(i = 0 ; i < 30 ; ++i)
+ {
+ p->begin_opByteSOneway(bs1, Test::newCallback_MyClass_opByteSOneway(new Callback_ByteSOneway3(), &Callback_ByteSOneway3::response, &Callback_ByteSOneway3::exception));
+ }
+
+ if(batch->ice_getConnection())
+ {
+ batch->ice_getConnection()->end_flushBatchRequests(batch->ice_getConnection()->begin_flushBatchRequests());
+
+ Test::MyClassPrx batch2 = Test::MyClassPrx::uncheckedCast(p->ice_batchOneway());
+
+ batch->begin_ice_ping();
+ batch2->begin_ice_ping();
+ batch->end_ice_flushBatchRequests(batch->begin_ice_flushBatchRequests());
+ batch->ice_getConnection()->close(false);
+ batch->begin_ice_ping();
+ batch2->begin_ice_ping();
+
+ batch->ice_getConnection();
+ batch2->ice_getConnection();
+
+ batch->begin_ice_ping();
+ batch->ice_getConnection()->close(false);
+
+ batch->begin_ice_ping(Ice::newCallback_Object_ice_ping(new Callback_ping(cb), &Callback_ping::response, &Callback_ping::exception));
+ cb->check();
+
+ batch2->begin_ice_ping(Ice::newCallback_Object_ice_ping(new Callback_ping(cb), &Callback_ping::response, &Callback_ping::exception));
+ cb->check();
+
+ batch->begin_ice_ping();
+ batch2->begin_ice_ping();
+ }
+
+ Ice::Identity identity;
+ identity.name = "invalid";
+ Ice::ObjectPrx batch3 = batch->ice_identity(identity);
+ batch3->begin_ice_ping();
+ batch3->end_ice_flushBatchRequests(batch3->begin_ice_flushBatchRequests());
+
+ // Make sure that a bogus batch request doesn't cause troubles to other ones.
+ batch3->begin_ice_ping();
+ batch->begin_ice_ping();
+ batch->end_ice_flushBatchRequests(batch->begin_ice_flushBatchRequests());
+ batch->begin_ice_ping();
+}
diff --git a/cpp/test/Ice/operations/Makefile b/cpp/test/Ice/operations/Makefile
index 2d57a5abb1e..80335c08a96 100644
--- a/cpp/test/Ice/operations/Makefile
+++ b/cpp/test/Ice/operations/Makefile
@@ -25,7 +25,8 @@ COBJS = Test.o \
TwowaysNewAMI.o \
OnewaysAMI.o \
OnewaysNewAMI.o \
- BatchOneways.o
+ BatchOneways.o \
+ BatchOnewaysAMI.o
SOBJS = Test.o \
TestI.o \
@@ -45,7 +46,8 @@ COLOBJS = Test.o \
TwowaysNewAMI.o \
OnewaysAMI.o \
OnewaysNewAMI.o \
- BatchOneways.o
+ BatchOneways.o \
+ BatchOnewaysAMI.o
SRCS = $(COBJS:.o=.cpp) \
$(SOBJS:.o=.cpp) \
diff --git a/cpp/test/Ice/operations/Makefile.mak b/cpp/test/Ice/operations/Makefile.mak
index 04b8523ffa1..367056a0b19 100644
--- a/cpp/test/Ice/operations/Makefile.mak
+++ b/cpp/test/Ice/operations/Makefile.mak
@@ -33,7 +33,8 @@ COBJS = Test.obj \
OnewaysAMI.obj \
TwowaysNewAMI.obj \
OnewaysNewAMI.obj \
- BatchOneways.obj
+ BatchOneways.obj \
+ BatchOnewaysAMI.obj
SOBJS = Test.obj \
TestI.obj \
@@ -54,6 +55,7 @@ COLOBJS = Test.obj \
TwowaysNewAMI.obj \
OnewaysNewAMI.obj \
BatchOneways.obj \
+ BatchOnewaysAMI.obj
SRCS = $(COBJS:.obj=.cpp) \
$(SOBJS:.obj=.cpp) \