Skip to content

Commit

Permalink
Replaced DCL pattern with static variable. Fixes #1364 (#1365)
Browse files Browse the repository at this point in the history
  • Loading branch information
git-afsantos authored and mikepurvis committed Apr 24, 2018
1 parent 2b3f43d commit b2fcb19
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 36 deletions.
14 changes: 2 additions & 12 deletions clients/roscpp/src/libros/connection_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,10 @@
namespace ros
{

ConnectionManagerPtr g_connection_manager;
boost::mutex g_connection_manager_mutex;
const ConnectionManagerPtr& ConnectionManager::instance()
{
if (!g_connection_manager)
{
boost::mutex::scoped_lock lock(g_connection_manager_mutex);
if (!g_connection_manager)
{
g_connection_manager = boost::make_shared<ConnectionManager>();
}
}

return g_connection_manager;
static ConnectionManagerPtr connection_manager = boost::make_shared<ConnectionManager>();
return connection_manager;
}

ConnectionManager::ConnectionManager()
Expand Down
14 changes: 2 additions & 12 deletions clients/roscpp/src/libros/poll_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,10 @@
namespace ros
{

PollManagerPtr g_poll_manager;
boost::mutex g_poll_manager_mutex;
const PollManagerPtr& PollManager::instance()
{
if (!g_poll_manager)
{
boost::mutex::scoped_lock lock(g_poll_manager_mutex);
if (!g_poll_manager)
{
g_poll_manager.reset(new PollManager);
}
}

return g_poll_manager;
static PollManagerPtr poll_manager = boost::make_shared<PollManager>();
return poll_manager;
}

PollManager::PollManager()
Expand Down
14 changes: 2 additions & 12 deletions clients/roscpp/src/libros/xmlrpc_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,10 @@ void getPid(const XmlRpcValue& params, XmlRpcValue& result)

const ros::WallDuration CachedXmlRpcClient::s_zombie_time_(30.0); // reap after 30 seconds

XMLRPCManagerPtr g_xmlrpc_manager;
boost::mutex g_xmlrpc_manager_mutex;
const XMLRPCManagerPtr& XMLRPCManager::instance()
{
if (!g_xmlrpc_manager)
{
boost::mutex::scoped_lock lock(g_xmlrpc_manager_mutex);
if (!g_xmlrpc_manager)
{
g_xmlrpc_manager.reset(new XMLRPCManager);
}
}

return g_xmlrpc_manager;
static XMLRPCManagerPtr xmlrpc_manager = boost::make_shared<XMLRPCManager>();
return xmlrpc_manager;
}

XMLRPCManager::XMLRPCManager()
Expand Down

0 comments on commit b2fcb19

Please sign in to comment.