#include <boost/weak_ptr.hpp>
+#include <map>
+
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
namespace isc {
namespace util {
+namespace { // unnamed namespace
+
+typedef std::map<std::string, boost::weak_ptr<isc::util::thread::Mutex> >
+ SyncMap;
+
+SyncMap&
+getSyncMap() {
+ // avoid static destruction fiasco when the SyncMap is destroyed
+ // before clients which use it such as logger objects. This leaks,
+ // but isn't a growing leak.
+ static SyncMap* sync_map = new SyncMap;
+
+ return (*sync_map);
+}
+
+Mutex&
+getSyncMapMutex() {
+ // avoid static destruction fiasco when the Mutex is destroyed
+ // before clients which use it such as logger objects. This leaks,
+ // but isn't a growing leak.
+ static Mutex* sync_map_mutex = new Mutex;
+
+ return (*sync_map_mutex);
+}
+
+} // end of unnamed namespace
+
InterprocessSyncFile::InterprocessSyncFile(const std::string& task_name) :
InterprocessSync(task_name),
fd_(-1)
// destruction when basic block is exited.
}
-InterprocessSyncFile::SyncMap&
-InterprocessSyncFile::getSyncMap() {
- // avoid static destruction fiasco when the SyncMap is destroyed
- // before clients which use it such as logger objects. This leaks,
- // but isn't a growing leak.
- static SyncMap* sync_map = new SyncMap;
-
- return (*sync_map);
-}
-
-Mutex&
-InterprocessSyncFile::getSyncMapMutex() {
- // avoid static destruction fiasco when the Mutex is destroyed
- // before clients which use it such as logger objects. This leaks,
- // but isn't a growing leak.
- static Mutex* sync_map_mutex = new Mutex;
-
- return (*sync_map_mutex);
-}
-
bool
InterprocessSyncFile::do_lock(int cmd, short l_type) {
// Open lock file only when necessary (i.e., here). This is so that
#include <boost/shared_ptr.hpp>
-#include <map>
#include <string>
namespace isc {
private:
typedef boost::shared_ptr<isc::util::thread::Mutex> MutexPtr;
typedef boost::shared_ptr<isc::util::thread::Mutex::Locker> LockerPtr;
- typedef std::map<std::string, boost::weak_ptr<isc::util::thread::Mutex> >
- SyncMap;
- SyncMap& getSyncMap();
- isc::util::thread::Mutex& getSyncMapMutex();
bool do_lock(int cmd, short l_type);
int fd_; ///< The descriptor for the open file