Moving out scheduler from dispatcher and sync-core constructors
diff --git a/src/dispatcher.cc b/src/dispatcher.cc
index 26e6e89..ba11b67 100644
--- a/src/dispatcher.cc
+++ b/src/dispatcher.cc
@@ -37,7 +37,7 @@
 Dispatcher::Dispatcher(const filesystem::path &path, const std::string &localUserName,
                        const std::string &sharedFolder,
                        const filesystem::path &rootDir, Ccnx::CcnxWrapperPtr ccnx,
-                       SchedulerPtr scheduler, int poolSize)
+                       int poolSize)
            : m_ccnx(ccnx)
            , m_core(NULL)
            , m_rootDir(rootDir)
@@ -59,7 +59,7 @@
   m_server->registerPrefix(syncPrefix);
 
   m_core = new SyncCore (m_syncLog, localUserName, Name ("/"), syncPrefix,
-                         bind(&Dispatcher::Did_SyncLog_StateChange, this, _1), ccnx, scheduler);
+                         bind(&Dispatcher::Did_SyncLog_StateChange, this, _1), ccnx);
 
   m_actionFetcher = make_shared<FetchManager> (m_ccnx, bind (&SyncLog::LookupLocator, &*m_syncLog, _1), 3);
   m_fileFetcher   = make_shared<FetchManager> (m_ccnx, bind (&SyncLog::LookupLocator, &*m_syncLog, _1), 3);
diff --git a/src/dispatcher.h b/src/dispatcher.h
index 3bb01b9..769723e 100644
--- a/src/dispatcher.h
+++ b/src/dispatcher.h
@@ -48,7 +48,7 @@
   // rootDir is the shared folder dir in local file system;
   Dispatcher(const boost::filesystem::path &path, const std::string &localUserName,
              const std::string &sharedFolder, const boost::filesystem::path &rootDir,
-             Ccnx::CcnxWrapperPtr ccnx, SchedulerPtr scheduler, int poolSize = 2);
+             Ccnx::CcnxWrapperPtr ccnx, int poolSize = 2);
   ~Dispatcher();
 
   // ----- Callbacks, they only submit the job to executor and immediately return so that event processing thread won't be blocked for too long -------
diff --git a/src/sync-core.cc b/src/sync-core.cc
index 9d2003d..8c653f1 100644
--- a/src/sync-core.cc
+++ b/src/sync-core.cc
@@ -36,13 +36,13 @@
 using namespace Ccnx;
 
 SyncCore::SyncCore(SyncLogPtr syncLog, const Name &userName, const Name &localPrefix, const Name &syncPrefix,
-                   const StateMsgCallback &callback, CcnxWrapperPtr ccnx, SchedulerPtr scheduler)
+                   const StateMsgCallback &callback, CcnxWrapperPtr ccnx)
   : m_ccnx (ccnx)
   , m_log(syncLog)
-         , m_scheduler(scheduler)
-         , m_stateMsgCallback(callback)
-         , m_syncPrefix(syncPrefix)
-         , m_recoverWaitGenerator(new RandomIntervalGenerator(WAIT, RANDOM_PERCENT, RandomIntervalGenerator::UP))
+  , m_scheduler(new Scheduler ())
+  , m_stateMsgCallback(callback)
+  , m_syncPrefix(syncPrefix)
+  , m_recoverWaitGenerator(new RandomIntervalGenerator(WAIT, RANDOM_PERCENT, RandomIntervalGenerator::UP))
 {
   m_rootHash = m_log->RememberStateInStateLog();
 
@@ -56,6 +56,7 @@
 
 SyncCore::~SyncCore()
 {
+  m_scheduler->shutdown ();
   // need to "deregister" closures
 }
 
diff --git a/src/sync-core.h b/src/sync-core.h
index bd7c5e8..48332da 100644
--- a/src/sync-core.h
+++ b/src/sync-core.h
@@ -44,8 +44,7 @@
            , const Ccnx::Name &localPrefix      // routable name used by the local user
            , const Ccnx::Name &syncPrefix       // the prefix for the sync collection
            , const StateMsgCallback &callback   // callback when state change is detected
-           , Ccnx::CcnxWrapperPtr ccnx
-           , SchedulerPtr scheduler);
+           , Ccnx::CcnxWrapperPtr ccnx);
   ~SyncCore();
 
   void
diff --git a/test/test-sync-core.cc b/test/test-sync-core.cc
index a7ab3c0..d18d4d4 100644
--- a/test/test-sync-core.cc
+++ b/test/test-sync-core.cc
@@ -61,13 +61,9 @@
   SyncLogPtr log1(new SyncLog(dir1, user1.toString()));
   SyncLogPtr log2(new SyncLog(dir2, user2.toString()));
 
-  // should not have used the same scheduler...
-  SchedulerPtr scheduler1 = make_shared<Scheduler> ();
-  SchedulerPtr scheduler2 = make_shared<Scheduler> ();
-
-  SyncCore *core1 = new SyncCore(log1, user1, loc1, syncPrefix, bind(callback, _1), c1, scheduler1);
+  SyncCore *core1 = new SyncCore(log1, user1, loc1, syncPrefix, bind(callback, _1), c1);
   usleep(10000);
-  SyncCore *core2 = new SyncCore(log2, user2, loc2, syncPrefix, bind(callback, _1), c2, scheduler2);
+  SyncCore *core2 = new SyncCore(log2, user2, loc2, syncPrefix, bind(callback, _1), c2);
   usleep(1000000);
   checkRoots(core1->root(), core2->root());