Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/loggers/bt_zmq_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ PublisherZMQ::PublisherZMQ(const BT::Tree& tree,
}
catch (zmq::error_t& err)
{
if (err.num() == ETERM)
Copy link
Contributor

@SteveMacenski SteveMacenski Dec 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not my code base to tell you what to do, but if without brackets makes my skin crawl. Might want to make it explicit like the styling of the rest of the file (+ L177 below). I've been burned alot by this in the past when working in codebases with python developers not realizing that only the 1st line after the if is used in the condition without brackets in C++.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The python perspective argument is really good.
This burned in somehow as a nice little c++ feature..
But better to skip stuff like that and keep it more readable / less future error prone..

Copy link
Contributor

@SteveMacenski SteveMacenski Dec 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also Mr. Explicit in my code, so I take the exact opposite extreme. I avoid auto unless the type is so long that I don't want to write it all out (and using it <2 times so not worth typedefing). Do as you like here, not up to me 😄

{
std::cout << "[PublisherZMQ] Server quitting." << std::endl;
}
std::cout << "[PublisherZMQ] just died. Exeption " << err.what() << std::endl;
active_server_ = false;
}
Expand All @@ -87,6 +91,7 @@ PublisherZMQ::PublisherZMQ(const BT::Tree& tree,
PublisherZMQ::~PublisherZMQ()
{
active_server_ = false;
zmq_->context.shutdown();
if (thread_.joinable())
{
thread_.join();
Expand Down Expand Up @@ -161,8 +166,20 @@ void PublisherZMQ::flush()
transition_buffer_.clear();
createStatusBuffer();
}

zmq_->publisher.send(message, 0);
try
{
zmq_->publisher.send(message, 0);
}
catch (zmq::error_t& err)
{
if (err.num() == ETERM)
{
std::cout << "[PublisherZMQ] Publisher quitting." << std::endl;
}
std::cout << "[PublisherZMQ] just died. Exeption " << err.what() << std::endl;
}


send_pending_ = false;
// printf("%.3f zmq send\n", std::chrono::duration<double>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count());
}
Expand Down