Skip to content

Commit

Permalink
DXEndpoint::awaitNotConnected()
Browse files Browse the repository at this point in the history
  • Loading branch information
ttldtor committed Mar 7, 2024
1 parent 2ee7ca6 commit 3c93e95
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 15 deletions.
7 changes: 6 additions & 1 deletion include/dxfeed_graal_cpp_api/api/DXEndpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ struct DXFCPP_EXPORT DXEndpoint : SharedEntity {

/**
* @return `true` if the endpoint is closed
* @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
*/
Expand Down Expand Up @@ -748,8 +749,12 @@ struct DXFCPP_EXPORT DXEndpoint : SharedEntity {
* <p><b>This method is blocking.</b>
*
* [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#awaitNotConnected--)
*
* @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 awaitNotConnected() noexcept;
void awaitNotConnected();

/**
* Waits until this endpoint stops processing data (becomes quiescent).
Expand Down
17 changes: 17 additions & 0 deletions include/dxfeed_graal_cpp_api/isolated/api/IsolatedDXEndpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ namespace isolated::api {

namespace IsolatedDXEndpoint {


//int32_t dxfg_DXEndpoint_connect(graal_isolatethread_t *thread, dxfg_endpoint_t *endpoint, const char *address);
//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_awaitNotConnected` 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 awaitNotConnected(/* dxfg_endpoint_t* */ const JavaObjectHandle<dxfcpp::DXEndpoint> &endpoint);

/**
* Calls the Graal SDK function in isolation to get the state of the endpoint.
*
Expand Down
16 changes: 2 additions & 14 deletions src/api/DXEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,8 @@ void DXEndpoint::disconnectAndClear() noexcept {
isolated::api::DXEndpoint::disconnectAndClear(handle_);
}

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

if (!handle_) {
return;
}

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

void DXEndpoint::awaitProcessed() 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 awaitNotConnected(/* dxfg_endpoint_t* */ const JavaObjectHandle<dxfcpp::DXEndpoint> &endpoint) {
if (!endpoint) {
throw std::invalid_argument(
"Unable to execute function `dxfg_DXEndpoint_awaitNotConnected`. The `endpoint` handle is invalid");
}

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

dxfcpp::DXEndpoint::State getState(/* dxfg_endpoint_t* */ const JavaObjectHandle<dxfcpp::DXEndpoint> &endpoint) {
if (!endpoint) {
throw std::invalid_argument("Unable to get state. The `endpoint` handle is invalid");
Expand Down

0 comments on commit 3c93e95

Please sign in to comment.