]> Dogcows Code - chaz/yoink/blobdiff - src/moof/runloop.hh
build system enhancements
[chaz/yoink] / src / moof / runloop.hh
index 0aad06dddaa9a25c82fc2f9d1e17c2c4af3d5667..29529521e8d16c96a35c4472fbe603e93396e8ce 100644 (file)
  * Thread timer management class.
  */
 
-#include <set>
+#include <vector>
 
 #include <boost/noncopyable.hpp>
 
-#include <moof/backend.hh>
 #include <moof/thread.hh>
 
 
@@ -35,7 +34,7 @@ class timer;
 /**
  * A runloop is a loop with scheduled timers.
  */
-class runloop
+class runloop : public boost::noncopyable
 {
 public:
 
@@ -43,13 +42,17 @@ public:
         * Construct a runloop.
         */
        runloop() :
-               stop_(false),
-               thread_id_(0) {}
+               stop_(false)
+       {
+#if ENABLE_THREADS
+               thread_id_ = 0;
+#endif
+       }
 
        /**
-        * Deconstruct the runloop.
+        * Do one iteration of the runloop.
         */
-       ~runloop();
+       void run_once();
 
 
        /**
@@ -65,25 +68,16 @@ public:
        void stop(int code = 0);
 
 
-       /** Get the runloop of the current thread.
-        * \return The current runloop or 0 if none is running in the current
-        * thread.
-        */
-       static runloop* current();
+       void add_timer(timer& timer);
+       void remove_timer(timer& timer);
 
 
 private:
 
-       friend class timer;
-
-       void add_timer(timer* timer);
-       void remove_timer(timer* timer);
-
-
        bool            stop_;
        int                     code_;
 
-       typedef std::set<timer*> timer_table;
+       typedef std::vector<timer*> timer_table;
        timer_table     timers_;
        timer_table::iterator timers_it_;
 
@@ -91,9 +85,6 @@ private:
        MOOF_DECLARE_MUTEX(timers_mutex_);
        uint32_t        thread_id_;
 #endif
-
-
-       backend         backend_;
 };
 
 
This page took 0.024511 seconds and 4 git commands to generate.