[Saga-devel] saga SVN commit 3323: /trunk/saga/saga/adaptors/utils/
amerzky at cct.lsu.edu
amerzky at cct.lsu.edu
Sat Jan 17 10:08:17 CST 2009
User: amerzky
Date: 2009/01/17 10:08 AM
Modified:
/trunk/saga/saga/adaptors/utils/
utils.cpp
Log:
adding scoped lock to make static vars thread safe
A
File Changes:
Directory: /trunk/saga/saga/adaptors/utils/
===========================================
File [modified]: utils.cpp
Delta lines: +9 -2
===================================================================
--- trunk/saga/saga/adaptors/utils/utils.cpp 2009-01-17 15:57:27 UTC (rev 3322)
+++ trunk/saga/saga/adaptors/utils/utils.cpp 2009-01-17 16:08:08 UTC (rev 3323)
@@ -14,6 +14,8 @@
#include <string>
#include <vector>
+#include <boost/thread.hpp>
+
#include <saga/saga/adaptors/utils/utils.hpp>
namespace saga
@@ -175,14 +177,19 @@
// a '.' in its name.
std::vector <std::string> get_localhosts (void)
{
- std::set <std::string> initial_names;
- std::set <std::string> names;
+ // scoped lock, to protect the static variables
+ boost::recursive_mutex mtx_;
+ boost::recursive_mutex::scoped_lock lock (mtx_);
// optimization: build this list only once - we assume that host names
// do not change during the runtime of the SAGA application.
static std::vector <std::string> localhosts;
static bool have_localhosts = false;
+
+ std::set <std::string> initial_names;
+ std::set <std::string> names;
+
if ( have_localhosts )
{
return localhosts;
More information about the saga-devel
mailing list