Skip to content

Commit

Permalink
[EN-7587] Implement FetchDailyCandles sample
Browse files Browse the repository at this point in the history
IsolatedDXFeedSubscription::addSymbols
  • Loading branch information
AnatolyKalin committed Jun 10, 2024
1 parent c2f8ebd commit 94d5421
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -112,19 +103,32 @@ addEventListener(/* dxfg_subscription_t * */ const JavaObjectHandle<DXFeedSubscr

// 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);

/**
* Calls the Graal SDK function `dxfg_DXFeedSubscription_addSymbol` in isolation.
*
* @param sub The subscription's handle.
* @param symbol The symbol.
* @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 */ addSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle<DXFeedSubscription> &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<DXFeedSubscription> &sub, /* dxfg_symbol_list * */ void* symbols);


/**
* Calls the Graal SDK function `dxfg_DXFeedSubscription_addChangeListener` in isolation.
*
Expand Down
11 changes: 1 addition & 10 deletions src/api/DXFeedSubscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,7 @@ void DXFeedSubscription::addSymbolImpl(void *graalSymbol) const {
}

void DXFeedSubscription::addSymbolsImpl(void *graalSymbolList) const {
if (!handle_) {
return;
}

runIsolatedOrElse(
[handle = static_cast<dxfg_subscription_t *>(handle_.get()), graalSymbolList](auto threadHandle) {
return dxfg_DXFeedSubscription_addSymbols(static_cast<graal_isolatethread_t *>(threadHandle), handle,
static_cast<dxfg_symbol_list *>(graalSymbolList)) == 0;
},
false);
isolated::api::IsolatedDXFeedSubscription::addSymbols(handle_, graalSymbolList);
}

void DXFeedSubscription::removeSymbolImpl(void *graalSymbol) const {
Expand Down
16 changes: 16 additions & 0 deletions src/isolated/api/IsolatedDXFeedSubscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ void /* int32_t */ addSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle<
static_cast<dxfg_symbol_t *>(symbol));
}

void /* int32_t */ addSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle<DXFeedSubscription> &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<dxfg_subscription_t *>(sub.get()),
static_cast<dxfg_symbol_list *>(symbols));
}

void /* int32_t */ addChangeListener(
/* dxfg_subscription_t * */ const JavaObjectHandle<DXFeedSubscription> &sub,
/* dxfg_observable_subscription_change_listener_t * */ const JavaObjectHandle<ObservableSubscriptionChangeListener>
Expand Down

0 comments on commit 94d5421

Please sign in to comment.