Skip to content

Commit

Permalink
DXEndpoint::awaitProcessed()
Browse files Browse the repository at this point in the history
  • Loading branch information
ttldtor committed Mar 7, 2024
1 parent 3c93e95 commit e8a72e4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
6 changes: 5 additions & 1 deletion include/dxfeed_graal_cpp_api/api/DXEndpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,12 @@ struct DXFCPP_EXPORT DXEndpoint : SharedEntity {
* all published data was written before closing this endpoint.
*
* [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#awaitProcessed--)
*
* @throws std::invalid_argument if endpoint handle is invalid.
* @throws JavaException if something happened with the dxFeed API backend
* @throws GraalException if something happened with the GraalVM
*/
void awaitProcessed() noexcept;
void awaitProcessed();

/**
* Closes this endpoint and wait until all pending data processing tasks are completed.
Expand Down
11 changes: 10 additions & 1 deletion include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXEndpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ namespace IsolatedDXEndpoint {
//int32_t dxfg_DXEndpoint_reconnect(graal_isolatethread_t *thread, dxfg_endpoint_t *endpoint);
//int32_t dxfg_DXEndpoint_disconnect(graal_isolatethread_t *thread, dxfg_endpoint_t *endpoint);
//int32_t dxfg_DXEndpoint_disconnectAndClear(graal_isolatethread_t *thread, dxfg_endpoint_t *endpoint);
//int32_t dxfg_DXEndpoint_awaitProcessed(graal_isolatethread_t *thread, dxfg_endpoint_t *endpoint);

/**
* Calls the Graal SDK function `dxfg_DXEndpoint_awaitProcessed` in isolation.
*
* @param endpoint The endpoint's handle.
* @throws std::invalid_argument if endpoint handle is invalid.
* @throws JavaException if something happened with the dxFeed API backend.
* @throws GraalException if something happened with the GraalVM.
*/
void awaitProcessed(/* dxfg_endpoint_t* */ const JavaObjectHandle<dxfcpp::DXEndpoint> &endpoint);

/**
* Calls the Graal SDK function `dxfg_DXEndpoint_awaitNotConnected` in isolation.
Expand Down
16 changes: 6 additions & 10 deletions src/api/DXEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,19 @@ void DXEndpoint::disconnectAndClear() noexcept {
}

void DXEndpoint::awaitNotConnected() {
if constexpr (Debugger::isDebug) {
Debugger::debug("DXEndpoint{" + handle_.toString() + "}::awaitNotConnected()");
}

isolated::api::IsolatedDXEndpoint::awaitNotConnected(handle_);
}

void DXEndpoint::awaitProcessed() noexcept {
void DXEndpoint::awaitProcessed() {
if constexpr (Debugger::isDebug) {
Debugger::debug("DXEndpoint{" + handle_.toString() + "}::awaitProcessed()");
}

if (!handle_) {
return;
}

runIsolatedOrElse(
[handle = static_cast<dxfg_endpoint_t *>(handle_.get())](auto threadHandle) {
return dxfg_DXEndpoint_awaitProcessed(static_cast<graal_isolatethread_t *>(threadHandle), handle) == 0;
},
false);
isolated::api::IsolatedDXEndpoint::awaitProcessed(handle_);
}

void DXEndpoint::closeAndAwaitTermination() noexcept {
Expand Down
10 changes: 10 additions & 0 deletions src/isolated/api/IsolatedDXEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ DXFCPP_BEGIN_NAMESPACE

namespace isolated::api::IsolatedDXEndpoint {

void awaitProcessed(/* dxfg_endpoint_t* */ const JavaObjectHandle<dxfcpp::DXEndpoint> &endpoint) {
if (!endpoint) {
throw std::invalid_argument(
"Unable to execute function `dxfg_DXEndpoint_awaitProcessed`. The `endpoint` handle is invalid");
}

runGraalFunctionAndThrowIfLessThanZero(dxfg_DXEndpoint_awaitProcessed,
static_cast<dxfg_endpoint_t *>(endpoint.get()));
}

void awaitNotConnected(/* dxfg_endpoint_t* */ const JavaObjectHandle<dxfcpp::DXEndpoint> &endpoint) {
if (!endpoint) {
throw std::invalid_argument(
Expand Down

0 comments on commit e8a72e4

Please sign in to comment.