Skip to content

Commit

Permalink
[EN-7587] Implement FetchDailyCandles sample
Browse files Browse the repository at this point in the history
IsolatedPromise
  • Loading branch information
ttldtor committed Jun 28, 2024
1 parent 009f8d8 commit 349dd21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions include/dxfeed_graal_cpp_api/isolated/IsolatedCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ constexpr auto throwIfMinusOne = [](auto v) {
return JavaException::throwIfMinusOne(v);
};

constexpr auto runGraalFunction(auto graalFunction, auto &&...params) {
return runIsolatedThrow(
[](auto threadHandle, auto &&graalFunction, auto &&...params) {
return graalFunction(static_cast<graal_isolatethread_t *>(threadHandle), params...);
},
graalFunction, params...);
}

constexpr auto runGraalFunctionAndThrow(auto resultCheckerConverter, auto graalFunction, auto &&...params) {
return runIsolatedThrow(
[](auto threadHandle, auto &&resultCheckerConverter, auto &&graalFunction, auto &&...params) {
Expand Down
8 changes: 4 additions & 4 deletions src/isolated/promise/IsolatedPromise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ std::shared_ptr<EventType> /* dxfg_event_type_t* */ getResult(/* dxfg_promise_ev
"Unable to execute function `dxfg_Promise_EventType_getResult`. The `promise` is nullptr");
}

auto *graalEvent =
runGraalFunctionAndThrowIfNullptr(dxfg_Promise_EventType_getResult, static_cast<dxfg_promise_t *>(promise));
auto *graalEvent = runGraalFunctionAndThrowIfNullptr(dxfg_Promise_EventType_getResult,
static_cast<dxfg_promise_event_t *>(promise));

auto result = dxfcpp::EventMapper::fromGraal(graalEvent);

Expand All @@ -69,7 +69,7 @@ getResults(/* dxfg_promise_events_t * */ void *promise) {
}

auto *graalEvents = runGraalFunctionAndThrowIfNullptr(dxfg_Promise_List_EventType_getResult,
static_cast<dxfg_promise_t *>(promise));
static_cast<dxfg_promise_events_t *>(promise));

auto result = dxfcpp::EventMapper::fromGraalList(graalEvents);

Expand All @@ -88,7 +88,7 @@ JavaException /* dxfg_exception_t* */ getException(/* dxfg_promise_t * */ void *

auto result = JavaException::create(graalException);

runGraalFunctionAndThrowIfLessThanZero(dxfg_Exception_release, graalException);
runGraalFunction(dxfg_Exception_release, graalException);

return result;
}
Expand Down

0 comments on commit 349dd21

Please sign in to comment.