diff --git a/include/dxfeed_graal_cpp_api/api/DXEndpoint.hpp b/include/dxfeed_graal_cpp_api/api/DXEndpoint.hpp index d8b8dfc4..b0abfc72 100644 --- a/include/dxfeed_graal_cpp_api/api/DXEndpoint.hpp +++ b/include/dxfeed_graal_cpp_api/api/DXEndpoint.hpp @@ -762,8 +762,12 @@ struct DXFCPP_EXPORT DXEndpoint : SharedEntity { * all published data was written before closing this endpoint. * * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#awaitProcessed--) + * + * @throws std::invalid_argument if endpoint handle is invalid. + * @throws JavaException if something happened with the dxFeed API backend + * @throws GraalException if something happened with the GraalVM */ - void awaitProcessed() noexcept; + void awaitProcessed(); /** * Closes this endpoint and wait until all pending data processing tasks are completed. diff --git a/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXEndpoint.hpp b/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXEndpoint.hpp index ac1ce93f..ced605f7 100644 --- a/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXEndpoint.hpp +++ b/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXEndpoint.hpp @@ -20,7 +20,16 @@ namespace IsolatedDXEndpoint { //int32_t dxfg_DXEndpoint_reconnect(graal_isolatethread_t *thread, dxfg_endpoint_t *endpoint); //int32_t dxfg_DXEndpoint_disconnect(graal_isolatethread_t *thread, dxfg_endpoint_t *endpoint); //int32_t dxfg_DXEndpoint_disconnectAndClear(graal_isolatethread_t *thread, dxfg_endpoint_t *endpoint); -//int32_t dxfg_DXEndpoint_awaitProcessed(graal_isolatethread_t *thread, dxfg_endpoint_t *endpoint); + +/** + * Calls the Graal SDK function `dxfg_DXEndpoint_awaitProcessed` in isolation. + * + * @param endpoint The endpoint's handle. + * @throws std::invalid_argument if endpoint handle is invalid. + * @throws JavaException if something happened with the dxFeed API backend. + * @throws GraalException if something happened with the GraalVM. + */ +void awaitProcessed(/* dxfg_endpoint_t* */ const JavaObjectHandle<dxfcpp::DXEndpoint> &endpoint); /** * Calls the Graal SDK function `dxfg_DXEndpoint_awaitNotConnected` in isolation. diff --git a/src/api/DXEndpoint.cpp b/src/api/DXEndpoint.cpp index cec59522..a5c002cb 100644 --- a/src/api/DXEndpoint.cpp +++ b/src/api/DXEndpoint.cpp @@ -193,23 +193,19 @@ void DXEndpoint::disconnectAndClear() noexcept { } void DXEndpoint::awaitNotConnected() { + if constexpr (Debugger::isDebug) { + Debugger::debug("DXEndpoint{" + handle_.toString() + "}::awaitNotConnected()"); + } + isolated::api::IsolatedDXEndpoint::awaitNotConnected(handle_); } -void DXEndpoint::awaitProcessed() noexcept { +void DXEndpoint::awaitProcessed() { if constexpr (Debugger::isDebug) { Debugger::debug("DXEndpoint{" + handle_.toString() + "}::awaitProcessed()"); } - if (!handle_) { - return; - } - - runIsolatedOrElse( - [handle = static_cast<dxfg_endpoint_t *>(handle_.get())](auto threadHandle) { - return dxfg_DXEndpoint_awaitProcessed(static_cast<graal_isolatethread_t *>(threadHandle), handle) == 0; - }, - false); + isolated::api::IsolatedDXEndpoint::awaitProcessed(handle_); } void DXEndpoint::closeAndAwaitTermination() noexcept { diff --git a/src/isolated/api/IsolatedDXEndpoint.cpp b/src/isolated/api/IsolatedDXEndpoint.cpp index 5aac8b81..ac70284d 100644 --- a/src/isolated/api/IsolatedDXEndpoint.cpp +++ b/src/isolated/api/IsolatedDXEndpoint.cpp @@ -13,6 +13,16 @@ DXFCPP_BEGIN_NAMESPACE namespace isolated::api::IsolatedDXEndpoint { +void awaitProcessed(/* dxfg_endpoint_t* */ const JavaObjectHandle<dxfcpp::DXEndpoint> &endpoint) { + if (!endpoint) { + throw std::invalid_argument( + "Unable to execute function `dxfg_DXEndpoint_awaitProcessed`. The `endpoint` handle is invalid"); + } + + runGraalFunctionAndThrowIfLessThanZero(dxfg_DXEndpoint_awaitProcessed, + static_cast<dxfg_endpoint_t *>(endpoint.get())); +} + void awaitNotConnected(/* dxfg_endpoint_t* */ const JavaObjectHandle<dxfcpp::DXEndpoint> &endpoint) { if (!endpoint) { throw std::invalid_argument(