diff --git a/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXFeedSubscription.hpp b/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXFeedSubscription.hpp index d127b828..bd41414f 100644 --- a/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXFeedSubscription.hpp +++ b/include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXFeedSubscription.hpp @@ -17,12 +17,6 @@ namespace isolated::api::IsolatedDXFeedSubscription { /* -int32_t dxfg_DXFeedSubscription_removeSymbol(graal_isolatethread_t *thread, dxfg_subscription_t *sub, -dxfg_symbol_t *symbol); - -int32_t dxfg_DXFeedSubscription_removeSymbols(graal_isolatethread_t *thread, dxfg_subscription_t *sub, -dxfg_symbol_list *symbols); - int32_t dxfg_DXFeedSubscription_clear(graal_isolatethread_t *thread, dxfg_subscription_t *sub); int32_t dxfg_DXFeedSubscription_attach(graal_isolatethread_t *thread, dxfg_subscription_t *sub, @@ -101,7 +95,8 @@ void /* int32_t */ addEventListener(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, /* dxfg_feed_event_listener_t * */ const JavaObjectHandle &listener); -// int32_t dxfg_DXFeedSubscription_removeEventListener(graal_isolatethread_t *thread, dxfg_subscription_t *sub, dxfg_feed_event_listener_t *listener); +// int32_t dxfg_DXFeedSubscription_removeEventListener(graal_isolatethread_t *thread, dxfg_subscription_t *sub, +// dxfg_feed_event_listener_t *listener); /** * Calls the Graal SDK function `dxfg_DXFeedSubscription_addSymbol` in isolation. @@ -112,10 +107,8 @@ 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); +void /* int32_t */ addSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_symbol_t * */ void *symbol); /** * Calls the Graal SDK function `dxfg_DXFeedSubscription_addSymbols` in isolation. @@ -126,8 +119,32 @@ void /* int32_t */ addSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle< * @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); +void /* int32_t */ addSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_symbol_list * */ void *symbols); + +/** + * Calls the Graal SDK function `dxfg_DXFeedSubscription_removeSymbol` in isolation. + * + * @param sub The subscription's handle. + * @param symbol The subscription's symbol. + * @throws std::invalid_argument if DXFeedSubscription's handle is invalid or the symbol is nullptr. + * @throws JavaException if something happened with the dxFeed API backend. + * @throws GraalException if something happened with the GraalVM. + */ +void /* int32_t */ removeSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_symbol_t * */ void *symbol); +/** + * Calls the Graal SDK function `dxfg_DXFeedSubscription_removeSymbols` 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 */ removeSymbols(/* 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 a68fead3..39c2aa6f 100644 --- a/src/api/DXFeedSubscription.cpp +++ b/src/api/DXFeedSubscription.cpp @@ -94,29 +94,11 @@ void DXFeedSubscription::addSymbolsImpl(void *graalSymbolList) const { } void DXFeedSubscription::removeSymbolImpl(void *graalSymbol) const { - if (!handle_) { - return; - } - - runIsolatedOrElse( - [handle = static_cast(handle_.get()), graalSymbol](auto threadHandle) { - return dxfg_DXFeedSubscription_removeSymbol(static_cast(threadHandle), handle, - static_cast(graalSymbol)) == 0; - }, - false); + isolated::api::IsolatedDXFeedSubscription::removeSymbol(handle_, graalSymbol); } void DXFeedSubscription::removeSymbolsImpl(void *graalSymbolList) const { - if (!handle_) { - return; - } - - runIsolatedOrElse( - [handle = static_cast(handle_.get()), graalSymbolList](auto threadHandle) { - return dxfg_DXFeedSubscription_removeSymbols(static_cast(threadHandle), handle, - static_cast(graalSymbolList)) == 0; - }, - false); + isolated::api::IsolatedDXFeedSubscription::removeSymbols(handle_, graalSymbolList); } void DXFeedSubscription::setSymbolsImpl(void *graalSymbolList) const { diff --git a/src/isolated/api/IsolatedDXFeedSubscription.cpp b/src/isolated/api/IsolatedDXFeedSubscription.cpp index 749bc9dc..9e89ab1a 100644 --- a/src/isolated/api/IsolatedDXFeedSubscription.cpp +++ b/src/isolated/api/IsolatedDXFeedSubscription.cpp @@ -71,7 +71,8 @@ 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) { +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"); @@ -87,6 +88,40 @@ void /* int32_t */ addSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle static_cast(symbols)); } +void /* int32_t */ removeSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_symbol_t * */ void *symbol) { + if (!sub) { + throw std::invalid_argument( + "Unable to execute function `dxfg_DXFeedSubscription_removeSymbol`. The `sub` handle is invalid"); + } + + if (!symbol) { + throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_removeSymbol`. The " + "`symbol` is nullptr"); + } + + runGraalFunctionAndThrowIfLessThanZero(dxfg_DXFeedSubscription_removeSymbol, + static_cast(sub.get()), + static_cast(symbol)); +} + +void /* int32_t */ removeSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle &sub, + /* dxfg_symbol_list * */ void *symbols) { + if (!sub) { + throw std::invalid_argument( + "Unable to execute function `dxfg_DXFeedSubscription_removeSymbols`. The `sub` handle is invalid"); + } + + if (!symbols) { + throw std::invalid_argument("Unable to execute function `dxfg_DXFeedSubscription_removeSymbols`. The " + "`symbols` is nullptr"); + } + + runGraalFunctionAndThrowIfLessThanZero(dxfg_DXFeedSubscription_removeSymbols, + 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