Skip to content

Commit

Permalink
[EN-7587] Implement FetchDailyCandles sample
Browse files Browse the repository at this point in the history
IsolatedDXFeedSubscription::removeSymbol
IsolatedDXFeedSubscription::removeSymbols
  • Loading branch information
AnatolyKalin committed Jun 10, 2024
1 parent 94d5421 commit dfe8fe2
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -101,7 +95,8 @@ void /* int32_t */
addEventListener(/* dxfg_subscription_t * */ const JavaObjectHandle<DXFeedSubscription> &sub,
/* dxfg_feed_event_listener_t * */ const JavaObjectHandle<DXFeedEventListener> &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.
Expand All @@ -112,10 +107,8 @@ addEventListener(/* dxfg_subscription_t * */ const JavaObjectHandle<DXFeedSubscr
* @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);
void /* int32_t */ addSymbol(/* dxfg_subscription_t * */ const JavaObjectHandle<DXFeedSubscription> &sub,
/* dxfg_symbol_t * */ void *symbol);

/**
* Calls the Graal SDK function `dxfg_DXFeedSubscription_addSymbols` in isolation.
Expand All @@ -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<DXFeedSubscription> &sub, /* dxfg_symbol_list * */ void* symbols);
void /* int32_t */ addSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle<DXFeedSubscription> &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<DXFeedSubscription> &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<DXFeedSubscription> &sub,
/* dxfg_symbol_list * */ void *symbols);

/**
* Calls the Graal SDK function `dxfg_DXFeedSubscription_addChangeListener` in isolation.
Expand Down
22 changes: 2 additions & 20 deletions src/api/DXFeedSubscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,29 +94,11 @@ void DXFeedSubscription::addSymbolsImpl(void *graalSymbolList) const {
}

void DXFeedSubscription::removeSymbolImpl(void *graalSymbol) const {
if (!handle_) {
return;
}

runIsolatedOrElse(
[handle = static_cast<dxfg_subscription_t *>(handle_.get()), graalSymbol](auto threadHandle) {
return dxfg_DXFeedSubscription_removeSymbol(static_cast<graal_isolatethread_t *>(threadHandle), handle,
static_cast<dxfg_symbol_t *>(graalSymbol)) == 0;
},
false);
isolated::api::IsolatedDXFeedSubscription::removeSymbol(handle_, graalSymbol);
}

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

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

void DXFeedSubscription::setSymbolsImpl(void *graalSymbolList) const {
Expand Down
37 changes: 36 additions & 1 deletion src/isolated/api/IsolatedDXFeedSubscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ 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) {
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");
Expand All @@ -87,6 +88,40 @@ void /* int32_t */ addSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle
static_cast<dxfg_symbol_list *>(symbols));
}

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

void /* int32_t */ removeSymbols(/* dxfg_subscription_t * */ const JavaObjectHandle<DXFeedSubscription> &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<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 dfe8fe2

Please sign in to comment.