Many improvements for the event scheduler

Another big change: maintaining an outstanding interests and
re-expressing this interest every 4 seconds (or 4 seconds after interest
is satisfied and expressed again)

Initial testing for SyncLogic
diff --git a/test/test_scheduler.cc b/test/test_scheduler.cc
index 9a72251..1dce279 100644
--- a/test/test_scheduler.cc
+++ b/test/test_scheduler.cc
@@ -45,6 +45,12 @@
 //   cout << "funcRemove\n";
 // }
 
+enum SCHEDULE_LABELS
+  {
+    TEST_LABEL,
+    ANOTHER_LABEL
+  };
+
 struct SchedulerFixture
 {
   SchedulerFixture ()
@@ -61,7 +67,9 @@
     counter ++;
 
     if (counter < 9)
-    scheduler->schedule (boost::posix_time::milliseconds (100), boost::bind (&SchedulerFixture::everySecond, this));
+    scheduler->schedule (boost::posix_time::milliseconds (100),
+                         boost::bind (&SchedulerFixture::everySecond, this),
+                         TEST_LABEL);
   }
 
   void setCounterFive ()
@@ -84,28 +92,40 @@
 {
   BOOST_CHECK_NO_THROW (scheduler = new Scheduler ());
 
-  scheduler->schedule (posix_time::milliseconds (100), bind (&SchedulerFixture::everySecond, this));
+  scheduler->schedule (posix_time::milliseconds (100),
+                       bind (&SchedulerFixture::everySecond, this),
+                       TEST_LABEL);
 
   sleep (1);
   // cout << counter << endl;
   BOOST_CHECK_EQUAL (counter, 9); // generally, should be 9
 
   scheduler->schedule (posix_time::seconds (2),
-		       bind (&SchedulerFixture::setCounterFive, this));
+		       bind (&SchedulerFixture::setCounterFive, this),
+                       TEST_LABEL);
 
   this_thread::sleep (posix_time::milliseconds (400)); // just in case
 
   scheduler->schedule (posix_time::milliseconds (600),
-		       bind (&SchedulerFixture::setCounterThree, this));
+		       bind (&SchedulerFixture::setCounterThree, this),
+                       TEST_LABEL);
 
   this_thread::sleep (posix_time::milliseconds (500));
   BOOST_CHECK_EQUAL (counter, 9); // still 9
-
+  
   this_thread::sleep (posix_time::milliseconds (200));
   BOOST_CHECK_EQUAL (counter, 3);
 
   this_thread::sleep (posix_time::milliseconds (1000));
   BOOST_CHECK_EQUAL (counter, 5);
+
+  scheduler->schedule (posix_time::milliseconds (100),
+		       bind (&SchedulerFixture::setCounterThree, this),
+                       ANOTHER_LABEL);
+  this_thread::sleep (posix_time::milliseconds (50));
+  scheduler->cancel (ANOTHER_LABEL);
+  this_thread::sleep (posix_time::milliseconds (150));
+  BOOST_CHECK_EQUAL (counter, 5);
   
   BOOST_CHECK_NO_THROW (delete scheduler);
 }
@@ -121,7 +141,7 @@
 {
 }
 
-BOOST_AUTO_TEST_CASE (SyncLogicTest)
+BOOST_AUTO_TEST_CASE (SyncLogicSchedulerTest)
 {  
   SyncLogic *logic = 0;
   BOOST_CHECK_NO_THROW (logic = new SyncLogic ("/prefix", funcUpdate, funcRemove, make_shared<CcnxWrapper> ()));
diff --git a/test/test_sync_logic.cc b/test/test_sync_logic.cc
new file mode 100644
index 0000000..27cd9c6
--- /dev/null
+++ b/test/test_sync_logic.cc
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ *         卞超轶 Chaoyi Bian <bcy@pku.edu.cn>
+ *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/output_test_stream.hpp> 
+#include <map>
+using boost::test_tools::output_test_stream;
+
+#include <boost/make_shared.hpp>
+
+#include "../model/sync-ccnx-wrapper.h"
+#include "../model/sync-logic.h"
+#include "../model/sync-seq-no.h"
+
+using namespace std;
+using namespace boost;
+using namespace Sync;
+
+struct Handler
+{
+  string instance;
+  
+  Handler (const string &_instance)
+  : instance (_instance)
+  {
+  }
+  
+  void onUpdate (const string &p/*prefix*/, const SeqNo &seq/*newSeq*/, const SeqNo &/*oldSeq*/)
+  {
+    cout << instance << "\t" << p << ": " << seq << endl;
+  }
+
+  void onRemove (const string &p/*prefix*/)
+  {
+    cout << instance << "\t" << p << endl;
+  }
+};
+
+BOOST_AUTO_TEST_CASE (SyncLogicTest)
+{
+  Handler h1 ("1"), h2 ("2");
+
+  SyncLogic l1 ("/bcast", bind (&Handler::onUpdate, &h1, _1, _2, _3), bind (&Handler::onRemove, &h1, _1), make_shared<CcnxWrapper> ());
+  SyncLogic L2 ("/bcast", bind (&Handler::onUpdate, &h2, _1, _2, _3), bind (&Handler::onRemove, &h2, _1), make_shared<CcnxWrapper> ());
+
+  sleep (10);
+  // l1.  
+}
+
+
+