added a clear() method to the TimerEventProxy to allow the removal of all pending...
[senf.git] / senf / Scheduler / TimerEventProxy.hh
index 08301ec..651a6b9 100644 (file)
 
 #include <senf/Scheduler/ClockService.hh>
 #include <senf/Scheduler/TimerEvent.hh>
-#include <senf/Utils/Console/Console.hh>
 
-///////////////////////////////hh.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 namespace senf {
 namespace scheduler {
 
     /** \brief Deadline timer proxy
 
-        The TimerEventProxy is meant to host long term deadline timers to reduce the load of the
+        The TimerEventProxy is meant to host long %term deadline timers to reduce the load of the
         Scheduler with a huge count of TimerEvent items. It registers deadline timer callbacks which
         will be called when the timer expires.
 
@@ -50,27 +49,31 @@ namespace scheduler {
         host a big count of timers.
      */
     template<typename IdType>
-    class TimerEventProxy 
+    class TimerEventProxy
     {
     public:
         typedef boost::function<void(ClockService::clock_type, IdType const &)> Callback;
 
-        TimerEventProxy();              ///< Instantiate a TimerEventProxy
-        TimerEventProxy(std::string const & name, console::DirectoryNode & node);
-                                        /**< \brief Instantiate a TimerEventProxy and add the list
-                                                    command to the give DirectoryNode */
-        
+        TimerEventProxy(std::string const & description = "");
+                                        ///< Instantiate a TimerEventProxy
+                                        /**< \param[in] description Descriptive name (purely informational) */
+
         void add(ClockService::clock_type timeout, IdType const & id, Callback cb);
                                         ///< Add new deadline timer
-        
+
         bool remove(IdType const & id); ///< Remove timer by given \a id.
-        
+
         std::vector<std::pair<ClockService::clock_type, IdType> > list() const;
                                         ///< Returns a vector of all active timers with timeout and id.
-        
+
         ClockService::clock_type timeout(IdType const & id) const;
                                         ///< Returns timeout for given id
-                                        /**< if no timer for this id is registered \a 0 is returned. */ 
+                                        /**< if no timer for this id is registered \a 0 is returned. */
+
+        unsigned numEvents() const;  ///< Returns the number of pending timer events 
+
+        void clear(); ///< Clears all pending timer events
+        
     private:
 #ifndef DOXYGEN
         struct Entry {
@@ -90,11 +93,11 @@ namespace scheduler {
             boost::multi_index::indexed_by<
                 boost::multi_index::ordered_non_unique<
                     boost::multi_index::tag<Timeout>,
-                    boost::multi_index::member<Entry, ClockService::clock_type, &Entry::timeout> 
+                    boost::multi_index::member<Entry, ClockService::clock_type, &Entry::timeout>
                 >,
                 boost::multi_index::ordered_unique<
                     boost::multi_index::tag<Id>,
-                    boost::multi_index::member<Entry, IdType, &Entry::id> 
+                    boost::multi_index::member<Entry, IdType, &Entry::id>
                 >
             >
         > EntrySet_t;
@@ -104,7 +107,7 @@ namespace scheduler {
         EntrySet_t entrySet;
         EntrySetById_t & entrySetById;
         EntrySetByTimeout_t & entrySetByTimeout;
-        
+
         scheduler::TimerEvent timer;
 
         void timerEvent();  // callback for the Scheduler timer event
@@ -112,7 +115,7 @@ namespace scheduler {
 
 }}
 
-///////////////////////////////hh.e////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 //#include "TimerEventProxy.cci"
 #include "TimerEventProxy.ct"
 //#include "TimerEventProxy.cti"