diff --git a/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXFeedSubscription.hpp b/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXFeedSubscription.hpp index 45bd494f..d127b828 100644 --- a/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXFeedSubscription.hpp +++ b/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXFeedSubscription.hpp @@ -17,15 +17,6 @@ namespace isolated::api::IsolatedDXFeedSubscription { /* -int32_t dxfg_DXFeedSubscription_removeEventListener(graal_isolatethread_t *thread, dxfg_subscription_t -*sub, dxfg_feed_event_listener_t *listener); - -int32_t dxfg_DXFeedSubscription_addSymbol(graal_isolatethread_t *thread, dxfg_subscription_t *sub, -dxfg_symbol_t *symbol); - -int32_t dxfg_DXFeedSubscription_addSymbols(graal_isolatethread_t *thread, dxfg_subscription_t *sub, -dxfg_symbol_list *symbols); - int32_t dxfg_DXFeedSubscription_removeSymbol(graal_isolatethread_t *thread, dxfg_subscription_t *sub, dxfg_symbol_t *symbol); @@ -112,19 +103,32 @@ addEventListener(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_symbol_t * */ void* symbol); +// int32_t dxfg_DXFeedSubscription_addSymbols(graal_isolatethread_t *thread, dxfg_subscription_t *sub, +// dxfg_symbol_list *symbols); + +/** + * Calls the Graal SDK function `dxfg_DXFeedSubscription_addSymbols` in isolation. + * + * @param sub The subscription's handle. + * @param symbols The subscription's symbols. + * @throws std::invalid_argument if DXFeedSubscription's handle is invalid or the symbols is nullptr. + * @throws JavaException if something happened with the dxFeed API backend. + * @throws GraalException if something happened with the GraalVM. + */ +void /* int32_t */ addSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_symbol_list * */ void* symbols); + + /** * Calls the Graal SDK function `dxfg_DXFeedSubscription_addChangeListener` in isolation. * diff --git a/src/api/DXFeedSubscription.cpp b/src/api/DXFeedSubscription.cpp index e6b62633..a68fead3 100644 --- a/src/api/DXFeedSubscription.cpp +++ b/src/api/DXFeedSubscription.cpp @@ -90,16 +90,7 @@ void DXFeedSubscription::addSymbolImpl(void *graalSymbol) const { } void DXFeedSubscription::addSymbolsImpl(void *graalSymbolList) const { - if (!handle_) { - return; - } - - runIsolatedOrElse( - [handle = static_cast(handle_.get()), graalSymbolList](auto threadHandle) { - return dxfg_DXFeedSubscription_addSymbols(static_cast(threadHandle), handle, - static_cast(graalSymbolList)) == 0; - }, - false); + isolated::api::IsolatedDXFeedSubscription::addSymbols(handle_, graalSymbolList); } void DXFeedSubscription::removeSymbolImpl(void *graalSymbol) const { diff --git a/src/isolated/api/IsolatedDXFeedSubscription.cpp b/src/isolated/api/IsolatedDXFeedSubscription.cpp index f4d37317..749bc9dc 100644 --- a/src/isolated/api/IsolatedDXFeedSubscription.cpp +++ b/src/isolated/api/IsolatedDXFeedSubscription.cpp @@ -71,6 +71,22 @@ void /* int32_t */ addSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle< static_cast(symbol)); } +void /* int32_t */ addSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_symbol_list * */ void* symbols) { + if (!sub) { + throw std::invalid_argument( + "Unable to execute function `dxfg_DXFeedSubscription_addSymbols`. The `sub` handle is invalid"); + } + + if (!symbols) { + throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_addSymbols`. The " + "`symbols` is nullptr"); + } + + runGraalFunctionAndThrowIfLessThanZero(dxfg_DXFeedSubscription_addSymbols, + static_cast(sub.get()), + static_cast(symbols)); +} + void /* int32_t */ addChangeListener( /* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_observable_subscription_change_listener_t * */ const JavaObjectHandle