Skip to content

Commit

Permalink
[core] send frequency calculation fixed in case of unconnected publis…
Browse files Browse the repository at this point in the history
…her (#1606)
  • Loading branch information
rex-schilasky authored May 17, 2024
1 parent 410aae0 commit 526ef8a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions ecal/core/src/readwrite/ecal_writer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -233,13 +233,6 @@ namespace eCAL

size_t CDataWriter::Write(CPayloadWriter& payload_, long long time_, long long id_)
{
{
// we should think about if we would like to potentially use the `time_` variable to tick with (but we would need the same base for checking incoming samples then....
const auto send_time = std::chrono::steady_clock::now();
const std::lock_guard<std::mutex> lock(m_frequency_calculator_mtx);
m_frequency_calculator.addTick(send_time);
}

// get payload buffer size (one time, to avoid multiple computations)
const size_t payload_buf_size(payload_.GetSize());

Expand Down Expand Up @@ -508,6 +501,15 @@ namespace eCAL
{
// increase write clock
m_clock++;

// update send frequency
{
// we should think about if we would like to potentially use the `time_` variable to tick with (but we would need the same base for checking incoming samples then....
const auto send_time = std::chrono::steady_clock::now();
const std::lock_guard<std::mutex> lock(m_frequency_calculator_mtx);
m_frequency_calculator.addTick(send_time);
}

}

std::string CDataWriter::Dump(const std::string& indent_ /* = "" */)
Expand Down

0 comments on commit 526ef8a

Please sign in to comment.