Skip to content

Commit

Permalink
Merge branch 'removeAddressPointers' into addingSeri
Browse files Browse the repository at this point in the history
  • Loading branch information
astro-friedel committed Nov 1, 2023
2 parents 90f3455 + d7b8219 commit eb54dcf
Show file tree
Hide file tree
Showing 39 changed files with 492 additions and 370 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS_RELEASE "/Zi -DNDEBUG -DYGG_DEBUG${BUILD_FLAGS}${YGG_BUILD_FLAGS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Zi -DNDEBUG -DYGG_DEBUG${BUILD_FLAGS}${YGG_BUILD_FLAGS}")
else ()
set(CMAKE_CXX_FLAGS_DEBUG "-g -DNDEBUG -DYGG_DEBUG${BUILD_FLAGS}${YGG_BUILD_FLAGS} ")
set(CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb -DYGG_DEBUG${BUILD_FLAGS}${YGG_BUILD_FLAGS} ")
set(CMAKE_CXX_FLAGS_RELEASE "-g -DNDEBUG -DYGG_DEBUG${BUILD_FLAGS}${YGG_BUILD_FLAGS} ")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -DNDEBUG -DYGG_DEBUG${BUILD_FLAGS}${YGG_BUILD_FLAGS} ")
endif ()
Expand Down Expand Up @@ -535,7 +535,7 @@ if(YGG_ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang|A
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
else()
target_link_libraries(YggInterface PRIVATE gcov)
target_link_libraries(${YGG_TARGET_CPP} PRIVATE gcov)
set(CTEST_COVERAGE_COMMAND "gcov")
set(CTEST_COVERAGE_EXTRA_FLAGS "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-inline-small-functions -fno-default-inline")
Expand All @@ -562,8 +562,8 @@ if(YGG_BUILD_TESTS)
set(SUBLIBFILE ${CMAKE_BINARY_DIR}/library_path.txt)
add_custom_command(
OUTPUT ${SUBLIBFILE}
COMMAND echo "$<TARGET_FILE:YggInterface>" > "${SUBLIBFILE}"
DEPENDS YggInterface
COMMAND echo "$<TARGET_FILE:${YGG_TARGET_CPP}>" > "${SUBLIBFILE}"
DEPENDS ${YGG_TARGET_CPP}
VERBATIM)
add_custom_target(make_sublib ALL DEPENDS ${SUBLIBFILE})

Expand Down
21 changes: 15 additions & 6 deletions communication/communicators/AsyncComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ bool AsyncBacklog::on_thread(Comm_t* parent) {
{
const std::lock_guard<std::mutex> comm_lock(comm_mutex);
int flgs_comm = (parent->getFlags() & ~COMM_FLAG_ASYNC) | COMM_FLAG_ASYNC_WRAPPED;
Address addr(parent->getAddress());
comm = new_Comm_t(direction,
parent->getCommType(),
parent->getName(),
new utils::Address(parent->getAddress()),
addr,
flgs_comm);
parent->updateMaxMsgSize(comm->getMaxMsgSize());
parent->address->address(comm->getAddress());
parent->address.address(comm->getAddress());
parent->updateMsgBufSize(comm->getMsgBufSize());
parent->getFlags() |= (comm->getFlags() & ~flgs_comm);
opened.store(true);
Expand Down Expand Up @@ -138,7 +139,7 @@ AsyncLockGuard::~AsyncLockGuard() {
///////////////

AsyncComm::AsyncComm(const std::string name,
utils::Address *address,
utils::Address& address,
const DIRECTION direction,
int flgs, const COMM_TYPE type) :
CommBase(name, address, direction, type, flgs | COMM_FLAG_ASYNC) {
Expand All @@ -153,9 +154,17 @@ AsyncComm::AsyncComm(const std::string name,
AsyncComm::AsyncComm(const std::string nme,
const DIRECTION dirn,
int flgs, const COMM_TYPE type) :
AsyncComm(nme, nullptr, dirn, flgs, type) {}
CommBase(nme, dirn, type, flgs | COMM_FLAG_ASYNC) {
if (type == SERVER_COMM)
this->direction = RECV;
else if (type == CLIENT_COMM)
this->direction = SEND;
if (!global_comm) {
handle = new AsyncBacklog(this);
}
}

AsyncComm::AsyncComm(utils::Address *addr,
AsyncComm::AsyncComm(utils::Address &addr,
const DIRECTION dirn,
int flgs, const COMM_TYPE type) :
AsyncComm("", addr, dirn, flgs, type) {}
Expand Down Expand Up @@ -251,7 +260,7 @@ bool AsyncComm::create_header_send(Header& header) {
return handle->comm->create_header_send(header);
}

Comm_t* AsyncComm::create_worker(utils::Address* address,
Comm_t* AsyncComm::create_worker(utils::Address& address,
const DIRECTION& dir, int flgs) {
return new AsyncComm("", address, dir, flgs | COMM_FLAG_WORKER, type);
}
8 changes: 4 additions & 4 deletions communication/communicators/AsyncComm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ namespace communication {
* @param flgs Bitwise flags describing the communicator
* @param type Enumerated communicator type
**/
explicit AsyncComm(const std::string name = "",
utils::Address *address = new utils::Address(),
explicit AsyncComm(const std::string name,
utils::Address& address,
const DIRECTION direction = NONE, int flgs = 0,
const COMM_TYPE type = DEFAULT_COMM);
explicit AsyncComm(const std::string nme,
const DIRECTION dirn, int flgs = 0,
const COMM_TYPE type = DEFAULT_COMM);
explicit AsyncComm(utils::Address *addr,
explicit AsyncComm(utils::Address &addr,
const DIRECTION dirn, int flgs = 0,
const COMM_TYPE type = DEFAULT_COMM);

Expand All @@ -81,7 +81,7 @@ namespace communication {
int send_single(utils::Header& header) override;
long recv_single(utils::Header& header) override;
bool create_header_send(utils::Header& header) override;
Comm_t* create_worker(utils::Address* address,
Comm_t* create_worker(utils::Address& address,
const DIRECTION& dir, int flgs) override;

};
Expand Down
17 changes: 12 additions & 5 deletions communication/communicators/ClientComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@ using namespace communication::utils;

unsigned ClientComm::_client_rand_seeded = 0;

ClientComm::ClientComm(const std::string nme, Address *addr,
ClientComm::ClientComm(const std::string nme, Address& addr,
int flgs, const COMM_TYPE type) :
RPCComm(nme, addr,
flgs | COMM_FLAG_CLIENT | COMM_ALWAYS_SEND_HEADER,
SEND, RECV, type) {
// Called to create temp comm for send/recv
if (!(global_comm || (name.empty() && address && address->valid())))
if (!(global_comm || (name.empty() && address.valid())))
init();
}

ClientComm::ClientComm(const std::string nme, int flgs, const COMM_TYPE type) :
RPCComm(nme, flgs | COMM_FLAG_CLIENT | COMM_ALWAYS_SEND_HEADER,
SEND, RECV, type) {
if (!(global_comm || (name.empty() && address.valid())))
init();
}

ADD_CONSTRUCTORS_RPC_DEF(ClientComm)

void ClientComm::set_timeout_recv(int new_timeout) {
Expand All @@ -44,7 +51,7 @@ void ClientComm::init() {
}
} YGG_THREAD_SAFE_END;
if (name.empty()) {
this->name = "client_request." + this->address->address();
this->name = "client_request." + this->address.address();
}
}

Expand Down Expand Up @@ -91,7 +98,7 @@ bool ClientComm::signon(const Header& header, Comm_t* async_comm) {
ygglog_debug << "ClientComm(" << name << ")::signon: Received response to signon" << std::endl;
break;
} else {
ygglog_debug << "ClientComm(" << name << ")::signon: No response to signon (address = " << requests.activeComm()->address->address() << "), sleeping" << std::endl;
ygglog_debug << "ClientComm(" << name << ")::signon: No response to signon (address = " << requests.activeComm()->address.address() << "), sleeping" << std::endl;
// Sleep outside lock on async
if (flags & COMM_FLAG_ASYNC_WRAPPED)
return true;
Expand Down Expand Up @@ -185,7 +192,7 @@ long ClientComm::recv_single(utils::Header& header) {
requests.transferSchemaFrom(response_comm);
}
} else {
ygglog_debug << "ClientComm(" << name << ")::recv_single: No response to oldest request (address = " << response_comm->address->address() << "), sleeping" << std::endl;
ygglog_debug << "ClientComm(" << name << ")::recv_single: No response to oldest request (address = " << response_comm->address.address() << "), sleeping" << std::endl;
std::this_thread::sleep_for(std::chrono::microseconds(YGG_SLEEP_TIME));

}
Expand Down
4 changes: 2 additions & 2 deletions communication/communicators/ClientComm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class ClientComm : public RPCComm {
* then an address will be created.
* @param flgs Bitwise flags describing the communicator
*/
explicit ClientComm(const std::string name = "",
utils::Address *address = nullptr,
explicit ClientComm(const std::string name,
utils::Address &address,
int flgs = 0, const COMM_TYPE type = CLIENT_COMM);
ADD_CONSTRUCTORS_RPC(ClientComm, CLIENT_COMM)

Expand Down
Loading

0 comments on commit eb54dcf

Please sign in to comment.