Skip to content

Commit

Permalink
registration provider single threaded sending
Browse files Browse the repository at this point in the history
Register(false) calls removed finally
  • Loading branch information
rex-schilasky committed Jul 26, 2024
1 parent 9110d2a commit fe4492e
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 133 deletions.
20 changes: 3 additions & 17 deletions ecal/core/src/readwrite/ecal_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ namespace eCAL

// mark as created
m_created = true;

// register
Register(false);
}

CDataReader::~CDataReader()
Expand Down Expand Up @@ -256,36 +253,25 @@ namespace eCAL

bool CDataReader::SetAttribute(const std::string& attr_name_, const std::string& attr_value_)
{
auto current_val = m_attr.find(attr_name_);

const bool force = current_val == m_attr.end() || current_val->second != attr_value_;
m_attr[attr_name_] = attr_value_;

#ifndef NDEBUG
// log it
Logging::Log(log_level_debug2, m_topic_name + "::CDataReader::SetAttribute");
#endif

// register it
Register(force);

return(true);
}

bool CDataReader::ClearAttribute(const std::string& attr_name_)
{
auto force = m_attr.find(attr_name_) != m_attr.end();

m_attr.erase(attr_name_);

#ifndef NDEBUG
// log it
Logging::Log(log_level_debug2, m_topic_name + "::CDataReader::ClearAttribute");
#endif

// register it
Register(force);

return(true);
}

Expand Down Expand Up @@ -533,10 +519,10 @@ namespace eCAL
return(out.str());
}

void CDataReader::Register(bool force_)
void CDataReader::Register()
{
#if ECAL_CORE_REGISTRATION
if (g_registration_provider() != nullptr) g_registration_provider()->ApplySample(GetRegistrationSample(), force_);
if (g_registration_provider() != nullptr) g_registration_provider()->RegisterSample(GetRegistrationSample());

#ifndef NDEBUG
// log it
Expand All @@ -548,7 +534,7 @@ namespace eCAL
void CDataReader::Unregister()
{
#if ECAL_CORE_REGISTRATION
if (g_registration_provider() != nullptr) g_registration_provider()->ApplySample(GetUnregistrationSample(), false);
if (g_registration_provider() != nullptr) g_registration_provider()->UnregisterSample(GetUnregistrationSample());

#ifndef NDEBUG
// log it
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/readwrite/ecal_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace eCAL
std::string Dump(const std::string& indent_ = "");

protected:
void Register(bool force_);
void Register();
void Unregister();

void CheckConnections();
Expand Down
45 changes: 17 additions & 28 deletions ecal/core/src/readwrite/ecal_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ namespace eCAL

// mark as created
m_created = true;

// register
Register(false);
}

CDataWriter::~CDataWriter()
Expand Down Expand Up @@ -227,7 +224,7 @@ namespace eCAL
if (m_writer_shm->PrepareWrite(wattr))
{
// register new to update listening subscribers and rematch
Register(true);
Register();
Process::SleepMS(5);
}

Expand Down Expand Up @@ -291,7 +288,7 @@ namespace eCAL
if (m_writer_udp->PrepareWrite(wattr))
{
// register new to update listening subscribers and rematch
Register(true);
Register();
Process::SleepMS(5);
}

Expand Down Expand Up @@ -364,53 +361,37 @@ namespace eCAL

bool CDataWriter::SetDataTypeInformation(const SDataTypeInformation& topic_info_)
{
// Does it even make sense to register if the info is the same???
const bool force = m_topic_info != topic_info_;
m_topic_info = topic_info_;

#ifndef NDEBUG
// log it
Logging::Log(log_level_debug2, m_topic_name + "::CDataWriter::SetDescription");
#endif

// register it
Register(force);

return(true);
}

bool CDataWriter::SetAttribute(const std::string& attr_name_, const std::string& attr_value_)
{
auto current_val = m_attr.find(attr_name_);

const bool force = current_val == m_attr.end() || current_val->second != attr_value_;
m_attr[attr_name_] = attr_value_;

#ifndef NDEBUG
// log it
Logging::Log(log_level_debug2, m_topic_name + "::CDataWriter::SetAttribute");
#endif

// register it
Register(force);

return(true);
}

bool CDataWriter::ClearAttribute(const std::string& attr_name_)
{
auto force = m_attr.find(attr_name_) != m_attr.end();

m_attr.erase(attr_name_);

#ifndef NDEBUG
// log it
Logging::Log(log_level_debug2, m_topic_name + "::CDataWriter::ClearAttribute");
#endif

// register it
Register(force);

return(true);
}

Expand Down Expand Up @@ -484,10 +465,10 @@ namespace eCAL
StartUdpLayer();
break;
case tl_ecal_shm:
if (StartShmLayer()) Register(true);
StartShmLayer();
break;
case tl_ecal_tcp:
if (StartTcpLayer()) Register(true);
StartTcpLayer();
break;
default:
break;
Expand Down Expand Up @@ -585,10 +566,10 @@ namespace eCAL
return(out.str());
}

void CDataWriter::Register(bool force_)
void CDataWriter::Register()
{
#if ECAL_CORE_REGISTRATION
if (g_registration_provider() != nullptr) g_registration_provider()->ApplySample(GetRegistrationSample(), force_);
if (g_registration_provider() != nullptr) g_registration_provider()->RegisterSample(GetRegistrationSample());

#ifndef NDEBUG
// log it
Expand All @@ -600,7 +581,7 @@ namespace eCAL
void CDataWriter::Unregister()
{
#if ECAL_CORE_REGISTRATION
if (g_registration_provider() != nullptr) g_registration_provider()->ApplySample(GetUnregistrationSample(), false);
if (g_registration_provider() != nullptr) g_registration_provider()->UnregisterSample(GetUnregistrationSample());

#ifndef NDEBUG
// log it
Expand All @@ -625,8 +606,7 @@ namespace eCAL
// check connection timeouts
CheckConnections();

if (m_created) return GetRegistrationSample();
else return GetUnregistrationSample();
return GetRegistrationSample();
}

Registration::Sample CDataWriter::GetRegistrationSample()
Expand Down Expand Up @@ -816,6 +796,9 @@ namespace eCAL
// create writer
m_writer_udp = std::make_unique<CDataWriterUdpMC>(m_host_name, m_topic_name, m_topic_id, m_config.layer.udp);

// register activated layer
Register();

#ifndef NDEBUG
Logging::Log(log_level_debug2, m_topic_name + "::CDataWriter::ActivateUdpLayer::WRITER_CREATED");
#endif
Expand All @@ -839,6 +822,9 @@ namespace eCAL
// create writer
m_writer_shm = std::make_unique<CDataWriterSHM>(m_host_name, m_topic_name, m_topic_id, m_config.layer.shm);

// register activated layer
Register();

#ifndef NDEBUG
Logging::Log(log_level_debug2, m_topic_name + "::CDataWriter::ActivateShmLayer::WRITER_CREATED");
#endif
Expand All @@ -862,6 +848,9 @@ namespace eCAL
// create writer
m_writer_tcp = std::make_unique<CDataWriterTCP>(m_host_name, m_topic_name, m_topic_id, m_config.layer.tcp);

// register activated layer
Register();

#ifndef NDEBUG
Logging::Log(log_level_debug2, m_topic_name + "::CDataWriter::ActivateTcpLayer::WRITER_CREATED");
#endif
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/readwrite/ecal_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace eCAL
std::string Dump(const std::string& indent_ = "");

protected:
void Register(bool force_);
void Register();
void Unregister();

void CheckConnections();
Expand Down
Loading

0 comments on commit fe4492e

Please sign in to comment.