Utils/Logger: Implement TimeSource facility
[senf.git] / Scheduler / Scheduler.hh
index e5c045c..babc199 100644 (file)
@@ -35,6 +35,7 @@
 #include <boost/call_traits.hpp>
 #include <boost/integer.hpp>
 #include "ClockService.hh"
+#include "../Utils/Logger/Target.hh"
 
 //#include "scheduler.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
@@ -116,8 +117,6 @@ namespace senf {
                 variable. The C++ standard then provides above guarantee. The instance will be
                 initialized the first time, the code flow passes the variable declaration found in
                 the instance() body.
-
-            \fixme TimerQueue as \c map \e and \c priority_queue doesn't make sense ...
          */
         static Scheduler & instance();
 
@@ -153,9 +152,7 @@ namespace senf {
                                         ///< Add timeout event
                                         /**< \param[in] timeout timeout in nanoseconds
                                              \param[in] cb callback to call after \a timeout
-                                                 milliseconds
-                                             \todo Return some kind of handle/pointer and add
-                                                 support to update or revoke a timeout */
+                                                 milliseconds */
 
         void cancelTimeout(unsigned id);
 
@@ -211,7 +208,7 @@ namespace senf {
         };
 
         typedef std::map<int,EventSpec> FdTable;
-        typedef std::map<unsigned,TimerSpec> TimerMap;
+        typedef std::map<unsigned,TimerSpec> TimerMap; // sorted by id
 
         struct TimerSpecCompare
         {
@@ -223,7 +220,7 @@ namespace senf {
         };
 
         typedef std::priority_queue<TimerMap::iterator, std::vector<TimerMap::iterator>, 
-                                    TimerSpecCompare> TimerQueue;
+                                    TimerSpecCompare> TimerQueue; // sorted by time
 
         FdTable fdTable_;
         unsigned timerIdCounter_;
@@ -243,6 +240,17 @@ namespace senf {
      */
     int retrieve_filehandle(int fd);
 
+    /** \brief Scheduler specific time source for Utils/Logger framework
+
+        This time source may be used to provide timing information for log messages within the
+        Utils/Logger framework. This time source will use Scheduler::eventTime() to provide timing
+        information.
+     */
+    struct SchedulerLogTimeSource : public senf::log::TimeSource
+    {
+        boost::posix_time::ptime operator()() const;
+    };
+
 }
 
 ///////////////////////////////hh.e////////////////////////////////////////