Skip to content

Commit

Permalink
InstrumentProfileConnection::close
Browse files Browse the repository at this point in the history
  • Loading branch information
ttldtor committed Oct 14, 2023
1 parent d9f1cf5 commit b9f4d27
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,16 @@ class DXFCPP_EXPORT InstrumentProfileConnection final : public SharedEntity {

/**
* Starts this instrument profile connection. This connection's state immediately changes to
* @ref InstrumentProfileConnection::State#CONNECTING "CONNECTING" and the actual connection establishment proceeds
* @ref InstrumentProfileConnection::State::CONNECTING "CONNECTING" and the actual connection establishment proceeds
* in the background.
*/
void start() const noexcept;

/**
* Closes this instrument profile connection. This connection's state immediately changes to
* @ref InstrumentProfileConnection::State::CLOSED "CLOSED" and the background update procedures are terminated.
*/
void close() const noexcept;
};

} // namespace dxfcpp
1 change: 1 addition & 0 deletions include/dxfeed_graal_cpp_api/isolated/Isolated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct InstrumentProfileConnection {
static dxfcpp::InstrumentProfileConnection::State getState(/* dxfg_ipf_connection_t * */ void* instrumentProfileConnectionHandle) noexcept;
static std::int64_t getLastModified(/* dxfg_ipf_connection_t * */ void* instrumentProfileConnectionHandle) noexcept;
static bool start(/* dxfg_ipf_connection_t * */ void* instrumentProfileConnectionHandle) noexcept;
static bool close(/* dxfg_ipf_connection_t * */ void* instrumentProfileConnectionHandle) noexcept;
};

struct InstrumentProfileList {
Expand Down
14 changes: 14 additions & 0 deletions src/internal/Isolate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,20 @@ bool InstrumentProfileConnection::start(
false, dxfcpp::bit_cast<dxfg_ipf_connection_t *>(instrumentProfileConnectionHandle));
}

bool InstrumentProfileConnection::close(
/* dxfg_ipf_connection_t * */ void *instrumentProfileConnectionHandle) noexcept {
if (!instrumentProfileConnectionHandle) {
return false;
}

return runIsolatedOrElse(
[](auto threadHandle, auto &&instrumentProfileConnectionHandle) {
return dxfg_InstrumentProfileConnection_close(dxfcpp::bit_cast<graal_isolatethread_t *>(threadHandle),
instrumentProfileConnectionHandle) == 0;
},
false, dxfcpp::bit_cast<dxfg_ipf_connection_t *>(instrumentProfileConnectionHandle));
}

bool InstrumentProfileList::release(/* dxfg_instrument_profile_list * */ void *graalInstrumentProfileList) noexcept {
if (!graalInstrumentProfileList) {
return false;
Expand Down
8 changes: 8 additions & 0 deletions src/ipf/live/InstrumentProfileConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,12 @@ void InstrumentProfileConnection::start() const noexcept {
isolated::ipf::InstrumentProfileConnection::start(handle_.get());
}

void InstrumentProfileConnection::close() const noexcept {
if (!handle_) {
return;
}

isolated::ipf::InstrumentProfileConnection::close(handle_.get());
}

} // namespace dxfcpp

0 comments on commit b9f4d27

Please sign in to comment.