One more modification of singleton (ability to destroy object)
diff --git a/ccnx/sync-app-socket.cc b/ccnx/sync-app-socket.cc
index 3da5402..e0b76de 100644
--- a/ccnx/sync-app-socket.cc
+++ b/ccnx/sync-app-socket.cc
@@ -39,6 +39,7 @@
SyncAppSocket::~SyncAppSocket()
{
+ CcnxWrapper::Destroy ();
}
bool
diff --git a/ccnx/sync-ccnx-wrapper.cc b/ccnx/sync-ccnx-wrapper.cc
index ba7e973..4759903 100644
--- a/ccnx/sync-ccnx-wrapper.cc
+++ b/ccnx/sync-ccnx-wrapper.cc
@@ -32,6 +32,7 @@
typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
typedef boost::error_info<struct tag_errmsg, int> errmsg_info_int;
+
using namespace std;
using namespace boost;
@@ -39,6 +40,8 @@
namespace Sync {
+boost::shared_ptr<CcnxWrapper> CcnxWrapper::s_wrapper;
+
#ifdef _DEBUG_WRAPPER_
CcnxWrapper::CcnxWrapper(char c)
#else
diff --git a/include/sync-ccnx-wrapper.h b/include/sync-ccnx-wrapper.h
index e2de36e..cc94a04 100644
--- a/include/sync-ccnx-wrapper.h
+++ b/include/sync-ccnx-wrapper.h
@@ -59,13 +59,25 @@
typedef boost::function<void (std::string, const char *buf, size_t len)> RawDataCallback;
typedef boost::function<void (std::string)> InterestCallback;
+private:
+ static boost::shared_ptr<CcnxWrapper> s_wrapper;
+public:
static
boost::shared_ptr<CcnxWrapper>
Create ()
{
- static boost::shared_ptr<CcnxWrapper> wrapper (new CcnxWrapper ());
- return wrapper;
+ if (s_wrapper.get () == 0)
+ s_wrapper = boost::shared_ptr<CcnxWrapper> (new CcnxWrapper ());
+
+ return s_wrapper;
+ }
+
+ static
+ void
+ Destroy ()
+ {
+ s_wrapper.reset ();
}
private:
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index 5280c93..141cf57 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -90,7 +90,11 @@
SyncLogic::~SyncLogic ()
{
+ m_ccnxHandle->clearInterestFilter (m_syncPrefix);
m_ccnxHandle.reset ();
+ // m_scheduler.cancel (REEXPRESSING_INTEREST);
+ // m_scheduler.cancel (DELAYED_INTEREST_PROCESSING);
+ // sleep (m_syncInterestReexpress+1);
}
#ifdef NS3_MODULE