Skip to content

Commit

Permalink
std bind and rearrage pub node fini
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
  • Loading branch information
iche033 committed Aug 7, 2020
1 parent 4bbe5eb commit c1e40a5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gazebo/transport/Publisher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ void Publisher::SendMessage()
{
// Send the latest message.
int result = this->publication->Publish(*iter,
boost::bind(&PublisherPrivate::OnPublishComplete,
pubDataPtr, _1), *pubIter);
std::bind(&PublisherPrivate::OnPublishComplete,
pubDataPtr, std::placeholders::_1), *pubIter);

std::lock_guard<std::mutex> lock2(pubDataPtr->mutex);
if (result > 0)
Expand Down Expand Up @@ -307,10 +307,12 @@ void Publisher::Fini()
if (!this->topic.empty())
TopicManager::Instance()->Unadvertise(this->topic, this->id);

this->node.reset();
{
std::lock_guard<std::mutex> lock(pubMapMutex);
publisherMap.erase(this->id);
}

std::lock_guard<std::mutex> lock(pubMapMutex);
publisherMap.erase(this->id);
this->node.reset();
}

//////////////////////////////////////////////////
Expand Down

0 comments on commit c1e40a5

Please sign in to comment.