diff options
author | Mark Spruiell <mes@zeroc.com> | 2016-12-09 15:18:08 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2016-12-09 15:18:08 -0800 |
commit | 3b7e9f99b61538e0bbd6f07deeb7f7cb12013ed5 (patch) | |
tree | a8edbf5d1043527cc50880b34ee83458ed7e4855 /python/modules/IcePy/Connection.cpp | |
parent | Merge remote-tracking branch 'origin/3.6' (diff) | |
download | ice-3b7e9f99b61538e0bbd6f07deeb7f7cb12013ed5.tar.bz2 ice-3b7e9f99b61538e0bbd6f07deeb7f7cb12013ed5.tar.xz ice-3b7e9f99b61538e0bbd6f07deeb7f7cb12013ed5.zip |
ICE-7138 - new Python AMI mapping based on futures and modified AMD mapping
Diffstat (limited to 'python/modules/IcePy/Connection.cpp')
-rw-r--r-- | python/modules/IcePy/Connection.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/python/modules/IcePy/Connection.cpp b/python/modules/IcePy/Connection.cpp index 2f5998bffc9..ec1e4f8db68 100644 --- a/python/modules/IcePy/Connection.cpp +++ b/python/modules/IcePy/Connection.cpp @@ -379,6 +379,50 @@ connectionFlushBatchRequests(ConnectionObject* self) extern "C" #endif static PyObject* +connectionFlushBatchRequestsAsync(ConnectionObject* self, PyObject* /*args*/, PyObject* /*kwds*/) +{ + assert(self->connection); + const string op = "flushBatchRequests"; + + FlushAsyncCallbackPtr d = new FlushAsyncCallback(op); + Ice::Callback_Connection_flushBatchRequestsPtr cb = + Ice::newCallback_Connection_flushBatchRequests(d, &FlushAsyncCallback::exception, &FlushAsyncCallback::sent); + + Ice::AsyncResultPtr result; + + try + { + AllowThreads allowThreads; // Release Python's global interpreter lock during remote invocations. + + result = (*self->connection)->begin_flushBatchRequests(cb); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return 0; + } + + PyObjectHandle communicatorObj = getCommunicatorWrapper(*self->communicator); + PyObjectHandle asyncResultObj = + createAsyncResult(result, 0, reinterpret_cast<PyObject*>(self), communicatorObj.get()); + if(!asyncResultObj.get()) + { + return 0; + } + + PyObjectHandle future = createFuture(op, asyncResultObj.get()); + if(!future.get()) + { + return 0; + } + d->setFuture(future.get()); + return future.release(); +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* connectionBeginFlushBatchRequests(ConnectionObject* self, PyObject* args, PyObject* kwds) { assert(self->connection); @@ -821,6 +865,8 @@ static PyMethodDef ConnectionMethods[] = PyDoc_STR(STRCAST("getAdapter() -> Ice.ObjectAdapter")) }, { STRCAST("flushBatchRequests"), reinterpret_cast<PyCFunction>(connectionFlushBatchRequests), METH_NOARGS, PyDoc_STR(STRCAST("flushBatchRequests() -> None")) }, + { STRCAST("flushBatchRequestsAsync"), reinterpret_cast<PyCFunction>(connectionFlushBatchRequestsAsync), + METH_NOARGS, PyDoc_STR(STRCAST("flushBatchRequestsAsync() -> Ice.Future")) }, { STRCAST("begin_flushBatchRequests"), reinterpret_cast<PyCFunction>(connectionBeginFlushBatchRequests), METH_VARARGS | METH_KEYWORDS, PyDoc_STR(STRCAST("begin_flushBatchRequests([_ex][, _sent]) -> Ice.AsyncResult")) }, { STRCAST("end_flushBatchRequests"), reinterpret_cast<PyCFunction>(connectionEndFlushBatchRequests), METH_VARARGS, |