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/model/sync-scheduler.cc b/model/sync-scheduler.cc
index 155e839..c5f1ca0 100644
--- a/model/sync-scheduler.cc
+++ b/model/sync-scheduler.cc
@@ -70,7 +70,10 @@
 	      // sleeping
 
 	      if (nextTime - get_system_time () > posix_time::time_duration (0,0,0,0))
-		continue; // something changes, try again
+                {
+                  // cout << "expected here" << endl;
+                  continue; // something changes, try again
+                }
 	    }
 
 	  if (!m_threadRunning) continue;
@@ -80,7 +83,11 @@
 	  {
 	    lock_guard<mutex> lock (m_eventsMutex);
 
-	    BOOST_ASSERT (m_events.size () != 0);
+	    if (m_events.size () == 0)
+              {
+                // cout << "Here" << endl;
+                continue;
+              }
 	    
 	    event = m_events.begin ()->event;
 	    m_events.erase (m_events.begin ());
@@ -88,7 +95,7 @@
 
 	  event (); // calling the event outside the locked mutex
         }
-      catch (thread_interrupted e)
+      catch (thread_interrupted &e)
         {
           // cout << "interrupted: " << this_thread::get_id () << endl;
           // do nothing
@@ -99,21 +106,35 @@
 
 
 void
-Scheduler::schedule (const boost::system_time &abstime, Event event)
+Scheduler::schedule (const boost::system_time &abstime, Event event, uint32_t label)
 {
   {
     lock_guard<mutex> lock (m_eventsMutex);
-    m_events.insert (LogicEvent (abstime, event));
+    m_events.insert (LogicEvent (abstime, event, label));
   }
   m_eventsCondition.notify_one ();
   m_thread.interrupt (); // interrupt sleep, if currently sleeping
 }
 
 void
-Scheduler::schedule (const boost::posix_time::time_duration &reltime, Event event)
+Scheduler::schedule (const boost::posix_time::time_duration &reltime, Event event, uint32_t label)
 {
   // cout << reltime << endl;
-  schedule (boost::get_system_time () + reltime, event);
+  schedule (boost::get_system_time () + reltime, event, label);
 }
 
+void
+Scheduler::cancel (uint32_t label)
+{
+  {
+    // cout << "Canceling label " << label << " size: " << m_events.size () << endl;
+    lock_guard<mutex> lock (m_eventsMutex);
+    m_events.get<byLabel> ().erase (label);
+    // cout << "Canceled label " << label << " size: " << m_events.size () << endl;
+  }
+  m_eventsCondition.notify_one ();
+  m_thread.interrupt (); // interrupt sleep, if currently sleeping
+}
+
+
 } // Sync